Introduction
If you’re using PostgreSQL, you may need to remove the package from your system at some point. It’s important to know how to uninstall PostgreSQL properly to make sure all components of the package are completely removed and you don’t encounter any errors. In this article, we’ll explain how to uninstall PostgreSQL from Linux, macOS and Windows operating systems.
NOTE: Be sure to elevate the privileges for any of the commands in this article with sudo
if the terminal returns a Permission denied
error.
Uninstall and remove PostgreSQL on Debian Linux
You can use the apt-get
command to completely remove PostgreSQL on a Debian-based distribution of Linux such as Linux Mint or Ubuntu:
1 |
sudo apt-get —purge remove postgresql |
Grep for all PostgreSQL packages in Debian Linux
You can use the dpkg
command for managing Debian packages, in conjunction with grep
, to search for all the package names installed that contain the sub-string postgres
. An example of this command is shown below:
Finally, make sure to use the APT-GET repository’s --purge remove
command, followed by the postgres
package name. This command will remove the package and purge all the data associated with it:
1 |
sudo apt-get —purge remove {POSTGRESS-PACKAGE NAME} |
Remove all of the PostgreSQL data and directories
Use the rm
command with the -rf
options to recursively remove all of the directories and data for the postgresql
packages:
1 |
sudo rm -rf /var/lib/postgresql/ |
After you complete your rm
commands, execute the dpkg -l | grep postgres
command one more time to verify that all of the packages have been removed.
Uninstall and remove PostgreSQL packages on Fedora Linux
You can use the YUM repository’s yum
command to uninstall PostgreSQL on Fedora-based distributions of Linux such Red Hat or CentOS:
To use a wildcard operator (*
) to remove all packages with names beginning with postgres
, use the following command:
Be sure to remove the pgsql
directory as well:
NOTE: Keep in mind that sudo
is not enabled for RHEL users by default. Instead, use the su
(switch user) command to enter as root
and execute the above commands with elevated privileges if necessary.
Grep for the PostgreSQL packages in Fedora using ‘rpm’
You can use the rpm
command with the -qa
options to grep for any packages that contain “postgres” in their name:
If you prefer, you can shorten the search to something like post
as well:
You can also use grep
in conjunction with YUM’s list
command to return a list of all package instances of PostgreSQL:
1 |
yum list installed | grep postgres |
Uninstall the PostgreSQL package using YUM remove
Once you’ve located the package, use YUM’s remove
command to uninstall PostgreSQL from your Linux system:
1 |
yum remove {POSTGRESS-PACKAGE NAME} |
Navigate to the assigned directory for the PostgreSQL data, and then use the rm
command to delete all of your databases and tables.
Uninstall and remove PostgreSQL from Windows
If you’re using Windows, type uninstall
or remove
into the search bar at the bottom left-hand side of the screen:
Then, follow the steps for the removal process, making sure to select the “Entire Components option when prompted.
You’ll see a pop-up stating something like: The data directory s(C:\Program Files\PostgreSQL\11\data) has not been removed
. Simply click “OK” to close the pop-up window, and do not select the option to restart your PC.
Delete the data folder for PostgreSQL in Windows
After you’ve completed the removal process described in the previous section, open File Explorer for Windows and navigate to the data
folder. Right-click the data folder and click the Delete button. Be sure to empty the recycle bin afterwards to ensure that any sensitive data has been properly deleted.
After all of the data has been deleted, you should restart Windows 10.
Uninstall and remove PostgreSQL on macOS
To uninstall PostgreSQL on macOS, open a new instance of Finder and navigate to the Applications directory. Look for the PostgreSQL folder and drag its contents to the Trash application folder in macOS.
Remove the PostgreSQL data in a terminal in macOS
After you’ve removed the PostgreSQL folder, open the Utilities folder in a Finder window, and then open the Terminal application.
Use the cd
command to navigate to the PostgreSQL
directory. You can do this by typing the directory path into the terminal prompt and pressing Return:
1 |
cd /Library/PostgreSQL/11 |
Then, use the rm -rf
command to remove the directory and its contents:
Don’t forget to empty the Trash application’s contents when you are finished.
Uninstall the Homebrew installation of PostgreSQL on macOS
You can use the brew
command in a macOS terminal window to remove the Homebrew version of PostgreSQL. First, use the list
command to return all of the applications installed using Homebrew:
Then, use the following command to force the removal the Homebrew installation of postgresql
:
1 |
brew uninstall —force postgresql |
Conclusion
If you find yourself needing to uninstall PostgreSQL, it’s important to do a careful and thorough job. Taking shortcuts when it comes to the removal process can leave sensitive data remaining on your machine. In this article, we explained how to uninstall and remove PostgreSQL from Windows, Linux and macOS. With the step-by-step instructions detailed in this tutorial, you’ll be ready to remove PostgreSQL from any of your own machines.
Postgres, or PostgreSQL, is an open-source object-relational database management system that is widely utilized for storing and managing data. Uninstalling Postgres from Windows means removing the Postgres software and all of its components from your computer. This can be necessary if Postgres is no longer needed on your system, or if you need to install a different version of Postgres.
This article will demonstrate a comprehensive guide on uninstalling Postgres from Windows.
What is the Purpose to Uninstall Postgres on Windows?
Uninstalling Postgres ensures that all of its files, configurations, and services are removed from the computer, freeing up disk space and resources. Additionally, it is useful if users are experiencing issues with Postgres and need to perform a clean installation to troubleshoot the problem.
Method: Using Control Panel to Uninstall Postgres
Uninstalling PostgreSQL on Windows can be done through the Control Panel or by using the PostgreSQL installer. Here are the steps to follow:
Step 1: Open the Control Panel
Go to the Windows Start menu and search for Control Panel, then click on it to open it:
Step 2: Go to “Programs and Features”
Once you reach the Control Panel, click on “Programs and Features” (or «Uninstall a program» depending on the version of Windows):
Step 3: Locate PostgreSQL
Scroll down the list of programs until you find PostgreSQL. Click on it to select it:
Step 4: Uninstall PostgreSQL
Click on the “Uninstall” button by pressing the right button of the mouse on the “PostgreSQL” program:
Follow the prompts to complete the uninstallation process:
Hit the “Next” button to begin the uninstallation of Postgres:
After completing the uninstallation, a new window will appear:
Hit the “Ok” button to finish.
Note: Once the uninstallation is done, the user can manually delete the PostgreSQL files and folders that were left behind. These can typically be found in the “Program Files” or “Program Files (x86)” folder in the Windows installation:
Remove the “PostgreSQL” directory to completely uninstall Postgres from your Windows system.
Conclusion
Uninstalling Postgres ensures that all of its files, configurations, and services are removed from the computer. To uninstall Postgres from windows, open the control panel > go to programs and features > locate PostgreSQL > Uninstall the PostgreSQL. This write-up demonstrated a step-by-step guide on uninstalling PostgreSQL from the Windows operating system.
Skip to content
PostgreSQL is a robust and Open Source relational database management system that has proven to be Scalable and Extensible.
You might want to uninstall PostgreSQL due to conflicts with other database software or when migrating to a different database system.
Uninstalling PostgreSQL can free up system resources and storage space, especially if it’s no longer needed for your project or application.
So let us go through how to uninstall PostgreSQL on Windows, Mac, and Linux.
- Removing PostgreSQL on Windows
- Removing PostgreSQL on Mac
- Removing PostgreSQL on Linux
Removing PostgreSQL on Windows
To uninstall PostgreSQL on Windows, you can follow these steps:[1][2]
- Stop the PostgreSQL service:
- To open the Run dialog box, press
Win + R
. - Type
services.msc
and press Enter to open up the Windows services panel. - Locate the PostgreSQL service, right-click on it, and select “Stop.”
- To open the Run dialog box, press
- Uninstall PostgreSQL using the Control Panel:
- Open the Windows Settings dialog box by pressing
Win + I
. - Go to “Apps” or “Apps & features” depending on your Windows version.
- Click on PostgreSQL, then click “Uninstall” or “Remove” and follow the uninstallation wizard.
- Open the Windows Settings dialog box by pressing
- Delete the PostgreSQL data directory (if necessary):
- The data directory is located in
C:\Program Files\PostgreSQL\<version>\data
by default.
- Delete this directory to remove all data associated with the PostgreSQL installation. Make sure you have a backup if you need this data.
- The data directory is located in
- Remove any remaining files or directories:
- After uninstallation, check if any files or directories related to PostgreSQL remain. These might be in the installation directory or elsewhere where PostgreSQL files were.
- Remove PostgreSQL from the system’s PATH (optional):
- Use the Windows search bar to find “Environment Variables” and select “Edit System Environment Variables.”
- Click on “Environment Variables” in the System Properties window.
- Under “System variables,” find the “Path” variable and select “Edit.”
- Remove any paths that include references to the PostgreSQL installation directory.
- Restart your computer.
Removing PostgreSQL on Mac
To uninstall PostgreSQL from your Mac, you will need to follow these general steps:[3]
- Stop PostgreSQL Server: If PostgreSQL is running, stop it. You can do this using the following command in your terminal:
sudo launchctl unload /Library/LaunchDaemons/org.postgresql.postgres.plist
- Remove PostgreSQL Files: After stopping the server, you can remove the PostgreSQL files. The exact locations may vary depending on your installation, but the default locations are:
- Remove the PostgreSQL Application:
sudo rm -rf /Library/PostgreSQL
- Remove Data Directory:
sudo rm -rf /Library/PostgreSQL/*version_number*/data
- Remove Configuration Files:
sudo rm -rf /etc/postgres-reg.ini
- Remove the PostgreSQL Application:
- Remove User Accounts: You may also want to remove the PostgreSQL user accounts. To do this, you can run the following command:
sudo dscl . -delete /Users/postgres
- Remove PostgreSQL System User: If you have a system user for PostgreSQL, you can remove it by running the following command:
sudo dscl . -delete /Users/_postgres
- Remove PostgreSQL Preferences and Cache Files: You may want to remove any preference and cache files related to PostgreSQL. The following commands do this:
sudo rm -rf ~/Library/Application\ Support/PostgreSQL
sudo rm -rf ~/Library/Caches/org.postgresql.PostgreSQL
- Remove any additional directories or files related to PostgreSQL that may have been created during the installation or use.
It’s a good idea to restart your machine after completing these steps.
Removing PostgreSQL on Linux
To uninstall PostgreSQL on a Linux system, you can follow these steps:[4]
- First, you need to stop the PostgreSQL service. Use the
Systemctl
command to do this. The service name might vary depending on your distribution, but common service names arepostgresql
orpostgresql-<version>
. Use the following command to stop the PostgreSQL service:sudo systemctl stop postgresql
- If you want to prevent PostgreSQL from starting on system boot, you can disable the service using the following command:
sudo systemctl disable postgresql
- The command to uninstall PostgreSQL varies depending on your Linux distribution.
- Ubuntu/Debian:
sudo apt-get purge postgresql postgresql-contrib && sudo apt-get autoremove
- CentOS/Fedora:
sudo dnf remove postgresql postgresql-server postgresql-contrib
- Ubuntu/Debian:
- Uninstalling PostgreSQL using the package manager doesn’t always remove configuration files and data. If you want to completely remove all PostgreSQL-related files, you can manually remove the PostgreSQL data directory and configuration files.
- Data directory is typically in
/var/lib/pgsql
or/var/lib/postgresql
. Use the following command to remove it:sudo rm -rf /var/lib/pgsql
- Configuration files are usually in
/etc/postgresql
. You can remove the configuration files with:sudo rm -rf /etc/postgresql
- Data directory is typically in
- PostgreSQL creates a system user and group during installation. You can remove them if you’re sure they’re no longer needed. Replace
<username>
and<groupname>
with the appropriate PostgreSQL user and group names (commonlypostgres
).sudo userdel <username> sudo groupdel <groupname>
- To remove any residual packages or dependencies that might not have been automatically removed, you can use the package manager’s cleanup command.
- Ubuntu/Debian:
sudo apt-get autoremove
- CentOS/Fedora:
sudo dnf autoremove
- Ubuntu/Debian:
After performing the above steps, you can reboot your system to ensure any lingering processes or services are completely terminated.
References
- Uninstalling PostgreSQL. (n.d.). https://www.enterprisedb.com/docs/supported-open-source/postgresql/uninstalling/ ↩︎
- Written by: Elijah Ugoh. (2023b, July 17). PostgreSQL download for free – 2024 Latest Version. WizCase. https://www.wizcase.com/download/postgresql/ ↩︎
- Stavniychuk, D. (2023b, November 30). Here is the correct way to uninstall PostgreSQL on Mac. MacPaw. https://macpaw.com/how-to/uninstall-postgressql-mac ↩︎
- How to completely uninstall PostgreSQL | ObjectRocket. (n.d.). https://kb.objectrocket.com/postgresql/how-to-completely-uninstall-postgresql-757 ↩︎
In this PostgreSQL tutorial, we will learn how to uninstall PostgreSQL from different operating systems. The possible reasons for uninstalling PostgreSQL could be the project is complete and you don’t need PostgreSQL, the software is at fault or broken, unable to update the PostgreSQL so want to reinstall with the latest version, etc.
- How to Uninstall PostgreSQL in Ubuntu
- How to uninstall PostgreSQL in Mac using Brew
- How to Uninstall PostgreSQL in Linux
- How to uninstall PostgreSQL in windows 10
In this section, we will learn how to completely uninstall PostgreSQL from Ubuntu. Ubuntu is the Debian package of Linux. We are using Ubuntu version 20.04 LTS but this method can be used for Ubuntu 16, 18, and 21.
- We are uninstalling PostgreSQL with all of its dependencies from the Ubuntu operating system. The entire process is divided into three parts.
- Uninstall the PostgreSQL application
- Remove dependencies
- Remove Folders
- Remove users (optional)
- To uninstall the PostgreSQL application we will use
purge
command. The Purge command in Linux removes the packages with configuration files.
sudo apt --purge remove postgresql -y
- Before we can remove PostgreSQL dependencies it is important to have a look on all the dependencies. We are calling this process important because even at this stage you can save things before it is gone forever.
- Dependencies can be removed by passing the name of each file mentioned in the above diagram.
- A screen will prompt asking for confirmation simply click enter for yes.
sudo apt-get --purge remove postgresql postgresql-13 postgresql-client-13 postgresql-client-common postgresql-common
- We have to remove three PostgreSQL folders that are present in lib, var and etc folders.
sudo rm -rf /var/lib/postgresql/
sudo rm -rf /var/log/postgresql/
sudo rm -rf /etc/postgresql/
- The last step in the process is to remove the users created in PostgreSQL. By default, we have Postgres user created while installing PostgreSQL. If you have created any other user you can remove it with the same command just by replacing the Postgres with your username.
sudo deluser postgres
Read: PostgreSQL installation on Linux step by step
How to Uninstall PostgreSQL in Mac using Brew
In this section, we will learn how to uninstall PostgreSQL in Mac using Brew. In our blog Install PostgreSQL on Macintosh (Mac) we have shared the installation of PostgreSQL through the PostgreSQL app. So in this section, we’ll see how to remove the PostgreSQL app in Mac.
- The best and easiest way to uninstall PostgreSQL completely from the Mac is by using the
uninstall-postgres.app. - Navigate to the directory /Library/PostgreSQL/13. Here 13 is the version of PostgreSQL installed in your system.
- There you will see a file uninstall-postgres.app, click to open the file.
- The screen will appear with two options, select Entire application and click the Next button.
- On the next screen, select all the checkboxes under the select components to uninstall and click on the Next button.
- PostgreSQL will be uninstalled from the Mac and a confirmation prompt for the same will appear on the screen.
How to Uninstall PostgreSQL in Linux
In this section, we will cover how to uninstall PostgreSQL in Linux. We have covered How to Uninstall PostgreSQL from Debian Package so now we will see how to uninstall PostgreSQL from the RPM package in Linux.
- RPM package include Red Hat, Centos, Fedora, etc. So if you are using one of these then you can follow the commands provided in this section.
- First step towards uninstalling Postgres in Linux is to view the packages and their dependencies. Below mentioned command will list all the packages and dependencies.
rpm -qa | grep postgres
- Last step in the process is to remove the PostgreSQL from Linux. We are removing all the packages with the command.
# remove all the packages
sudo yum remove postgres\*
How to uninstall PostgreSQL in windows 10
In this section, we will learn how to uninstall PostgreSQL in Windows 10. These steps can be followed on Windows 7 and windows 8, 8.1.
- Open Control Panel
- Right-click on the Postgres 13 and select uninstall
- Select the radio button ‘Entire application‘ and click on Next.
- Select all the checkboxes and click on Next.
- A prompt will appear confirming that PostgreSQL has been uninstalled.
You may like the following PostgreSQL tutorials:
- How to connect to PostgreSQL database
- How to create a table in PostgreSQL [Terminal + pgAdmin]
- How to Restart PostgreSQL (Linux, Windows, Mac)
- PostgreSQL CASE with Examples
In this tutorial, we have learned how to uninstall PostgreSQL from different operating systems. Also, we have covered these topics.
- How to Uninstall PostgreSQL in Ubuntu
- How to Uninstall PostgreSQL in Mac using Brew
- How to Uninstall PostgreSQL in Linux
- How to uninstall PostgreSQL in windows 10
I am Bijay having more than 15 years of experience in the Software Industry. During this time, I have worked on MariaDB and used it in a lot of projects. Most of our readers are from the United States, Canada, United Kingdom, Australia, New Zealand, etc.
Want to learn MariaDB? Check out all the articles and tutorials that I wrote on MariaDB. Also, I am a Microsoft MVP.
Need Space in PC or only want to remove or uninstall PostgreSQL On PC ( Windows 7, 8, 10, and Mac )? but how to, after it still having files in C: drive? With this article, you will able to delete or kick out all of those files also after uninstalling the PostgreSQL.
Are you bored, or tired of using PostgreSQL? Now, wanna kick-off this software from your PC ( Windows 7, 8, 10, and Mac )? There is no condition to follow up before installing, so, you can remove it without getting any confusion about it.
There are 10 methods that users can adapt if they want to uninstall PostgreSQL :
Method #1
- Go to Start Menu, then click on the Control Panel.
- In Control Panel, under programs, go through the list of the ones that are installed on your computer
- Right-click on PostgreSQL, and then click on uninstall a program
- Follow the prompt on the screen, and you will get to see a progress bar that will take you to remove the PostgreSQL from the computer.
Method #2
The second method involves uninstaller.exe, through which PostgreSQL can be uninstalled. Just follow the instructions below to execute this step:
- Go to the installation folder of PostgreSQL.
- Find a file that is named uninstall.exe or unins000.exe
- Double click on the file, and then follow the instructions that appear on the screen.
Method #3
The third method involves System Restore. For those who don’t know, System Restore is a utility, which helps the user restore their system to its previous state. System Restore removes all those programs, which interfere with the operation and performance of the computer.
If you have created a system restore point before you installed PostgreSQL, then you can use this software to restore the system, and remove such unwanted programs. However, before you do so, make sure that you save all the important data.Follow the steps below to know more from this method:
- Close all the files and programs, which are currently running on your PC
- Open Computer from the desktop, and then select Properties
- System Window will open
- On the left side and click on System Protection
- System Properties will open.
- Then do click on the option of System Restore, and a new window will again open.
- Now, choose the ‘different restore point’ option, and click on Next.
- You have to select a date and time from the given options; when you select a date, the drivers that you installed after the chosen date won’t work.
- Click on Finish and then Confirm the ‘Restore Point’ on the screen.
- When you click Yes to confirm, the PostgreSQL would be uninstalled.
Method #4
If you have an antivirus, then you can use it to uninstall PostgreSQL.There is much malware or PostgreSQL software in the computer applications that we download nowadays. They have become very difficult to remove from the system, like Trojan and spyware.
- If you cannot remove PostgreSQL with the above methods.
- It means that there is malware or PostgreSQL in it, and only a good antivirus can be used for removing it.
You can either download Norton Antivirus or AVG antivirus, as these are reputable software and will surely remove the malware, PostgreSQL on the system.
Method #5
If you want to uninstall PostgreSQL, then you can do so using Command Displayed in the Registry. A registry is a place where all the settings of Windows, along with information, are stored. This also includes the command to uninstall a software or program.
You can try this method with PostgreSQL as well, but it is a very risky method. If you make any mistake and delete the wrong information, then the system is most likely to crash. It would become difficult for you to bring it back from deletion.
To execute this method, To follow the steps given below:
- Hold Windows + R together, and then Run command
- When the command box opens, type Regedit in the box and then click on OK
- You have to navigate and find the registry key for the PostgreSQL
- You will see an uninstall string on the next window; double click on it, and also copy ‘Value Data’
- Again hold Windows + R keys, and run the Command; paste the value data that you just copy and click on OK
Follow what comes on the screen and then uninstall PostgreSQL.
Method #6
The seventh method is to uninstall the PostgreSQL using a third-party uninstaller.
At times, those who don’t have any knowledge of computer language, won’t be able to manually uninstall the software fully.
Many files occupy the hard disk of the computer, so it is best to use third-party software to uninstall them.
Method #7
There are some codes that users can type into the command prompt, and they would be able to uninstall the PostgreSQL. For example, if they want to remove the package, then just type.
sudo apt-get remove PostgreSQL
If you want to uninstall PostgreSQL and its dependencies as well, then type:
sudo apt-get remove –auto-remove PostgreSQL
For those who don’t know, some of the dependencies of PostgreSQL are GCC-5, libc6, libgcc1, PostgreSQL dev, and gc++-5.
Method #8
If the user wants to remove the configuration and data files of PostgreSQL, then they need to run the following code on the Command Prompt:
sudo apt-get purge PostgreSQL
Method # 9
It depends on you that are you willing to kick-out the data or you want to remove the configuration data or data files, along with the dependencies, then the following code is most likely to work for you:
sudo apt-get auto-remove -purge PostgreSQL
To uninstall PostgreSQL on mac because anytime we need space or only want to remove from pc due to some viruses and also many problems which are needed to remove or uninstall from pc.
So I will show you some steps of uninstalling PostgreSQL on the mac so follow my this step or method if you have still confusion so you may contact with us for uninstall of PostgreSQL on pc or mac.
How to Uninstall PostgreSQL on Mac?
For uninstalling PostgreSQL on the mac so as I told you that there is a simple method to uninstall apps on mac. As there are installed some apps on your Mac and now you want to remove or uninstall from your pc successfully and want to install some other apps on my mac so follow my these steps to uninstall PostgreSQL on mac.
Method #1
In method 1, you have to open mac on your pc as I’m showing in the image follow the images to uninstall PostgreSQL on your mac.
In the image, there is a PostgreSQL app on your mac dashboard and now we have to uninstall it from our mac we will uninstall this app and will remove it in of mac now double-click-on-app showing in the image.
Now you double-clicked on the app mac will ask that are you sure to uninstall PostgreSQL click on the Delete button so go to Trash of mac to uninstall completely from mac. Showing in image trash bin click on trash bin and go inside there will be PostgreSQL which we had to delete before so have to uninstall completely from mac.
Not right-click on trash to remove all data or app which we had uninstalled before seeing in the image. Click on Empty Trash the whole data which is in the trash will auto remove successfully.
Now we uninstalled PostgreSQL on the mac so as you see that how to uninstall or remove any app on the mac so if you liked this so share once. This method doesn’t require any antivirus or uninstaller software from them we are to uninstall.
I described only a simple method of uninstalling PostgreSQL on mac. This method more people are using but some people take it is too hard uninstalling in mac but in this step, anyone can understand this simple method.
How To Install?
For those who don’t know much about PostgreSQL, they might lean more towards uninstalling it. These PostgreSQL create an environment, where users can create a high GPU-accelerated application. If you want to install this PostgreSQL, then make sure that your system is compatible with it.
Firstly, verify that the system you are using has a PostgreSQL capable GPU, and then download the PostgreSQL. Install it, and then test that the software runs smoothly on the system. If it doesn’t run smoothly, then it could be because its communication with the hardware is corrupted.
Conclusion
There are other methods of uninstalling the PostgreSQL as well as in pc or windows, but these could be difficult for those, who don’t have much technical expertise. Execute these methods, and they will surely work. These methods don’t require the user to have much knowledge of the technical side of an operating system. They can follow simple steps and uninstall PostgreSQL.