If you’ve installed PostgreSQL on your Mac for a project and no longer need it, it’s a good idea to uninstall it. That will help free up space on your Mac and prevent the possibility of conflicts with other files and software that could cause problems. In this article, we’ll explain the options for uninstalling PostgreSQL.
What is PostgreSQL?
Dating all the way back to 1982, PostgreSQL is a system for managing relational databases that is focused on allowing users to extend their capabilities and SQL compliance. It was the default database for macOS Server, but it also runs on Windows, Linux, FreeBSD, and OpenBSD. It’s free and open source. It can handle workloads on individual machines, web services, and data warehouses as well as support multiple concurrent users. It can also be used with services like AWS (Amazon Web Services).
Why uninstall PostgreSQL?
The main reason for uninstalling it, as with any tool you no longer use, is to prevent problems further down the line. If you’re not using software, it’s unlikely that you will keep it updated. And out-of-date software is a common cause of conflicts and can even leave your Mac vulnerable to malware attacks.
Now, let’s find out how to remove PostgreSQL from Mac. There are two options for uninstalling. One easy, one not so easy. Let’s tackle the easy method first; then, we’ll show you the not-so-easy way.
How to uninstall PostgreSQL the easy way
This method uses a tool designed to uninstall apps and their leftover files that may take up too much space on your Mac. The tool is CleanMyMac, and as well as uninstalling and updating apps, it has a bunch of other features that can clear the clutter from your Mac and keep it running smoothly. You can download it for free here.
- Open CleanMyMac.
- Go to Applications from the left sidebar.
- Click Scan.
- Search for PostgreSQL and select the box next to it.
- Click Uninstall.
That’s it. That’s all you need to do to completely uninstall PostgreSQL with CleanMyMac.
How to uninstall PostgreSQL manually
You’ll need to use the Terminal for this, but if you’ve used PostgreSQL, using the Terminal shouldn’t be an issue.
First, though, you need to shut down the server if it’s running on your Mac: click the elephant icon in the toolbar and choose “Shutdown server.”
Next, there are a couple of options for Terminal commands, depending on how you installed PostgreSQL. Try them in the order below. Only use the second one if the first is unsuccessful.
- Go to Applications > Utilities and open Terminal.
- Type the following command:
open /Library/PostgreSQL/9.2/uninstall-postgresql.app
- Press Return and type in your admin password when prompted.
- Follow the instructions on the screen.
If that doesn’t work, use this command:
- Type this command and then hit Return:
sudo /Library/PostgreSQL/9.1/uninstall-postgresql.app/Contents/MacOS/installbuilder.sh
- Type in your admin password when prompted.
- Follow the instructions on the screen.
It’s possible that even though the Terminal commands above uninstall PostgreSQL, they will leave files on your startup disk. To get rid of those, you will need to run a couple more commands in Terminal:
- Type
sudo rm /etc/postgres-reg.ini
- Press Return.
- Type
sudo rm -rf /Library/PostgreSQL
- Press Return.
Finally, you will need to remove the PostgreSQL user account from your Mac:
- Click the Apple menu and choose System Settings.
- Choose Users & Groups.
- Select the PostgreSQL user.
- Click the i icon and choose Delete Account. Note that you cannot do it for the account you are logged in to.
- Quit System Settings.
PostgreSQL should now be completely uninstalled.
PostgreSQL is a relational database management tool that may have been installed on your Mac by you or a previous user. If you don’t use it anymore, follow the steps above to uninstall and remove all of its files from your Mac.
Frequently asked questions
How to check if PostgreSQL is running?
You can use the following command: ps aux | grep postgres
If it is running, you’ll see some postgre processes. Or you can open Activity Monitor from Applications > Utilities and search postgre processes there.
How to find PostgreSQL version?
There is a command that can help you find PostgreSQL version: psql -–version
Or you can expand the Servers tree, left-click PostgreSQL > Properties via pgAdmin and look for the needed information there.
How to backup PostgreSQL database?
You will first have to log in to the PostgreSQL server and run a superuser. Use this command:
su – postgres
Next, use pg_dump
to backup one database at a time: pg_dump -U username -h hostname -p portnumber -F databasename > filename.sql