197

This question may look like a duplicate of: How to uninstall postgresql on my Mac (running Snow Leopard) however, there are two major differences. I'm running Lion and I'm trying to uninstall PostgreSQL 9.0.4. I've looked at the last question and the link that it referenced, but I did not find a file called "uninstall-postgresql" when I run this command:

sudo find / -name "*uninstall-*"  

So, I assume this means that the uninstall process for 9.0.4 is different than that of 8.x.

I've seen a couple of posts in different places describing a method for manual uninstallation but, similarly, some of the directories/files referenced are not present on my machine.

Any assistance or direction you can provide would be greatly appreciated.

Just for reference, this is the link the other poster used to uninstall postgres from snow leopard. As I tried to step through these commands, most of them choked with some variant of "command not found".


UPDATE:

In addition to brew uninstall postgres, should I remove any of the following files/directories manually? Keep in mind I want to completely wipe the slate clean, no data files/database tables or anything.

> sudo find / -name "*postgres*"             
find: /dev/fd/3: Not a directory
find: /dev/fd/4: Not a directory
/Library/Ruby/Gems/1.8/doc/activerecord-3.1.1/rdoc/lib/active_record/connection_adapters/postgresql_adapter_rb.html
/Library/Ruby/Gems/1.8/doc/activerecord-3.1.1/ri/ActiveRecord/ConnectionAdapters/PostgreSQLAdapter/postgresql_version-i.ri
/Library/Ruby/Gems/1.8/doc/arel-2.2.1/rdoc/lib/arel/visitors/postgresql_rb.html
/Library/Ruby/Gems/1.8/gems/activerecord-3.1.1/lib/active_record/connection_adapters/postgresql_adapter.rb
/Library/Ruby/Gems/1.8/gems/arel-2.2.1/lib/arel/visitors/postgresql.rb
/Library/Ruby/Gems/1.8/gems/arel-2.2.1/test/visitors/test_postgres.rb
/Library/Ruby/Gems/1.8/gems/railties-3.1.1/lib/rails/generators/rails/app/templates/config/databases/jdbcpostgresql.yml
/Library/Ruby/Gems/1.8/gems/railties-3.1.1/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml
/Library/WebServer/Documents/postgresql
/Library/WebServer/Documents/postgresql/html/app-postgres.html
/Library/WebServer/Documents/postgresql/html/postgres-user.html
/private/etc/apache2/users/postgres.conf
/private/var/db/dslocal/nodes/Default/groups/_postgres.plist
/private/var/db/dslocal/nodes/Default/sharepoints/postgres's Public Folder.plist
/private/var/db/dslocal/nodes/Default/users/_postgres.plist
/private/var/db/dslocal/nodes/Default/users/postgres.plist
/System/Library/DirectoryServices/DefaultLocalDB/Default/groups/_postgres.plist
/System/Library/DirectoryServices/DefaultLocalDB/Default/users/_postgres.plist
/Users/postgres
/Users/remcat/dev/working/startwire/vendor/plugins/foreign_keys/lib/foreign_keys/postgresql_adapter.rb
/Users/remcat/Library/Application Support/CrashReporter/postgres_DCCEF98F-4602-5FF7-964F-5E717AC007B4.plist
/Users/remcat/Library/Caches/Homebrew/postgresql-9.0.4.tar.bz2
/Users/remcat/Library/Caches/Metadata/Safari/History/http:%2F%2Fwww.postgresql.org%2Fdocs%2Fcurrent%2Fstatic%2Findex.html.webhistory
/Users/remcat/Library/Logs/CrashReporter/postgres_2011-11-06-194716_Ramys-MacBook-Pro.crash
/Users/remcat/Library/Logs/CrashReporter/postgres_2011-11-06-194742_Ramys-MacBook-Pro.crash
/Users/remcat/Library/Logs/CrashReporter/postgres_2011-11-06-194757_Ramys-MacBook-Pro.crash
/Users/remcat/Library/Logs/CrashReporter/postgres_2011-11-06-194958_Ramys-MacBook-Pro.crash
/Users/remcat/Library/Logs/CrashReporter/postgres_2011-11-06-203352_Ramys-MacBook-Pro.crash
/Users/remcat/Library/Logs/CrashReporter/postgres_2011-11-06-203359_Ramys-MacBook-Pro.crash
/Users/remcat/Library/Logs/DiagnosticReports/.postgres_2011-11-06-194716_Ramys-MacBook-Pro.crash.plist
/Users/remcat/Library/Logs/DiagnosticReports/.postgres_2011-11-06-194742_Ramys-MacBook-Pro.crash.plist
/Users/remcat/Library/Logs/DiagnosticReports/.postgres_2011-11-06-194757_Ramys-MacBook-Pro.crash.plist
/Users/remcat/Library/Logs/DiagnosticReports/.postgres_2011-11-06-194958_Ramys-MacBook-Pro.crash.plist
/Users/remcat/Library/Logs/DiagnosticReports/.postgres_2011-11-06-203352_Ramys-MacBook-Pro.crash.plist
/Users/remcat/Library/Logs/DiagnosticReports/.postgres_2011-11-06-203359_Ramys-MacBook-Pro.crash.plist
/Users/remcat/Library/Logs/DiagnosticReports/postgres_2011-11-06-194716_Ramys-MacBook-Pro.crash
/Users/remcat/Library/Logs/DiagnosticReports/postgres_2011-11-06-194742_Ramys-MacBook-Pro.crash
/Users/remcat/Library/Logs/DiagnosticReports/postgres_2011-11-06-194757_Ramys-MacBook-Pro.crash
/Users/remcat/Library/Logs/DiagnosticReports/postgres_2011-11-06-194958_Ramys-MacBook-Pro.crash
/Users/remcat/Library/Logs/DiagnosticReports/postgres_2011-11-06-203352_Ramys-MacBook-Pro.crash
/Users/remcat/Library/Logs/DiagnosticReports/postgres_2011-11-06-203359_Ramys-MacBook-Pro.crash
/Users/remcat/Library/Saved Application State/org.postgresql.pgadmin.savedState
/usr/bin/postgres_real
/usr/include/postgres_ext.h
/usr/include/postgresql
/usr/include/postgresql/internal/postgres_fe.h
/usr/include/postgresql/server/postgres.h
/usr/include/postgresql/server/postgres_ext.h
/usr/include/postgresql/server/postgres_fe.h
/usr/lib/postgresql
/usr/local/Library/Aliases/postgres
/usr/local/Library/Formula/postgresql.rb
/usr/local/var/postgres
/usr/local/var/postgres/postgresql.conf
/usr/share/devicemgr/backend/vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
/usr/share/devicemgr/backend/vendor/rails/railties/configs/databases/postgresql.yml
/usr/share/devicemgr/webserver/gems/gems/eventmachine-0.12.10/lib/em/protocols/postgres3.rb
/usr/share/man/man1/postgres.1.gz
/usr/share/postgresql
/usr/share/postgresql/postgres.bki
/usr/share/postgresql/postgres.description
/usr/share/postgresql/postgres.shdescription
/usr/share/postgresql/postgresql.conf
/usr/share/postgresql/postgresql.conf.sample
Community
  • 1
  • 1
Ramy
  • 20,541
  • 41
  • 103
  • 153

10 Answers10

796

The following is the un-installation for PostgreSQL 9.1 installed using the EnterpriseDB installer. You most probably have to replace folder /9.1/ with your version number. If /Library/Postgresql/ doesn't exist then you probably installed PostgreSQL with a different method like homebrew or Postgres.app.

To remove the EnterpriseDB One-Click install of PostgreSQL 9.1:

  1. Open a terminal window. Terminal is found in: Applications->Utilities->Terminal
  2. Run the uninstaller:

    sudo /Library/PostgreSQL/9.1/uninstall-postgresql.app/Contents/MacOS/installbuilder.sh
    

    If you installed with the Postgres Installer, you can do:

    open /Library/PostgreSQL/9.2/uninstall-postgresql.app
    

    It will ask for the administrator password and run the uninstaller.

  3. Remove the PostgreSQL and data folders. The Wizard will notify you that these were not removed.

    sudo rm -rf /Library/PostgreSQL
    
  4. Remove the ini file:

    sudo rm /etc/postgres-reg.ini
    
  5. Remove the PostgreSQL user using System Preferences -> Users & Groups.

    1. Unlock the settings panel by clicking on the padlock and entering your password.
    2. Select the PostgreSQL user and click on the minus button.
  6. Restore your shared memory settings:

    sudo rm /etc/sysctl.conf
    

That should be all! The uninstall wizard would have removed all icons and start-up applications files so you don't have to worry about those.

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
user1181328
  • 7,981
  • 2
  • 13
  • 4
  • 5
    Currently 9.2 is the latest, replace '9.1' with '9.2' and this still works. – James Wald Sep 23 '12 at 23:13
  • Awesome! I had to change the version number but other than that, spot on, and a huge SAVORE ! – jahrichie Nov 26 '12 at 16:07
  • I just ran the 9.2 installer, and it said it changed my shared memory settings and that to restore them to default, I should delete `/etc/sysctl.conf`. I've added that to the answer. – Heath Borders Dec 17 '12 at 17:43
  • /Library/Postgresql might also be missing if the default install location was overriden – Gus Jan 10 '13 at 22:41
  • 3
    After uninstalling postgresql 9.2, Apache stopped working. `sudo /usr/sbin/httpd` give me `dyld: Library not loaded: /usr/lib/libpq.5.dylib`. To fix that quickly I created a link `sudo ln -s /usr/lib/libpq.5.3.dylib /usr/lib/libpq.5.dylib` – grandouassou Jan 28 '13 at 15:54
  • @florian - I had the same issue. If you installed a newer version, you cannot use this proceedure to remove the older one because the uninstaller will remove some library files that are shared by both versions. FYI. – user9645 Nov 01 '13 at 07:38
  • Worked on Mavericks for 9.3 BUT the last step (#6) couldn't find `/etc/sysctl.conf` so perhaps it has moved or is now irrelevant. – Fitter Man Jul 14 '14 at 12:47
  • 43
    In that last step I could not find the `sysctl.conf` file. Perhaps this is no longer relevant with Postgres 9.4 as the shared memory is [no longer reconfigured for a large size](http://www.postgresql.org/docs/9.4/static/kernel-resources.html). – Basil Bourque Oct 13 '14 at 04:35
  • Still works great in 9.6rc1. As @BasilBourque said there is no `/etc/sysctl.conf'. It doesn't seem to be created automatically but the docs for 9.5+ say that it's **recommended to create one manually** on osx. See: [postgres docs shared mem and semaphores](https://www.postgresql.org/docs/current/static/kernel-resources.html) section OSX. – klaas Sep 14 '16 at 19:58
  • 34
    why is this such a nightmare – SuperUberDuper Aug 17 '17 at 15:36
  • @klaas I suspect that “macOS” section of [the page you linked](https://www.postgresql.org/docs/current/static/kernel-resources.html) may be outdated, though I am not certain. – Basil Bourque May 16 '18 at 22:18
  • 2
    I've upgraded to Catalina and now I'm getting `./uninstall-postgresql.app/Contents/MacOS/uninstall-postgresql: Bad CPU type in executable`... I completely forgot EDB apps are all 32-bit. – msr_overflow Dec 06 '19 at 21:23
  • @msr_overflow same problem here... :( – Hussam Mar 30 '20 at 19:44
  • 1
    Thank you! This works on EDB postgresSQL version 13. – yveszenne Sep 29 '20 at 15:31
  • the best way to do this – angry kiwi Nov 13 '20 at 18:54
131

homebrew Installer

Assuming you installed PostgreSQL with homebrew as referenced in check status of postgresql server Mac OS X and how to start postgresql server on mac os x: you can use the brew uninstall postgresql command.

EnterpriseDB Installer

If you used the EnterpriseDB installer then see the other answer in this thread.

The EnterpriseDB installer is what you get if you follow "download" links from the main Postgres web site. The Postgres team releases only source code, so the EnterpriseDB.com company builds installers as a courtesy to the community.

Postgres.app

You may have also used Postgres.app.

This double-clickable Mac app contains the Postgres engine.

Community
  • 1
  • 1
James Allman
  • 40,573
  • 11
  • 57
  • 70
  • 1
    tanks again @JamesA. do i need to remove anything manually in order to be sure the slate is wiped completely clean? You can check my latest update with the output of "sudo find" – Ramy Nov 07 '11 at 15:26
  • 1
    also, is it adviseable to try and install using the "one click installer" found at postgres.org? (version 9.0.5) – Ramy Nov 07 '11 at 16:18
  • 9
    @Ramy The `brew uninstall` command should clean up everything necessary. You could remove the */usr/local/var/postgres* folder if it still exists prior to reinstalling if you want to make sure it's completely cleaned up. I don't work with Ruby so I can't offer any suggestions there. – James Allman Nov 07 '11 at 16:26
  • @Ramy I found the EnterpriseDB one click installer to be a pain compared to the Homebrew installation. – James Allman Nov 07 '11 at 16:27
  • well, i've installed postgres using the one-click installer. Everything seems to be kosher so far. thanks again for all your help, @JamesA – Ramy Nov 07 '11 at 16:50
  • How do I uninstall PostgreSQL after installing it via the EnterpriseDB Installer? – ericn Jul 30 '15 at 08:51
  • is the mac app better than brew? – SuperUberDuper Feb 29 '16 at 22:36
  • don't use Postgres.app with a 10 foot poll, it will cause you a world of pain – SuperUberDuper Aug 17 '17 at 13:31
  • How do I uninstall the Postgress app? Using the instructions on the site (essentially dragging the .app file to the trash) and re-installing yields the same errors as before. – Hatchmaster J Jul 02 '18 at 05:55
28

I don't use the same version, but uninstall actions are the same: Looking for file uninstall-postgresql inside directory

/Library/PostgreSQL/9.6

enter image description here

then run it.

enter image description here

(Screenshot in macOS 10.13)

then

sudo rm -rf /Library/PostgreSQL/

to delete all unnecessary directory.

Vy Do
  • 46,709
  • 59
  • 215
  • 313
28

This blog post explains very well:

(just replace 9.X by your version. e.g: 9.6)

A. If installed PostgreSQL with homebrew, enter brew uninstall postgresql

B. If you used the EnterpriseDB installer, follow the following step.

Run the uninstaller on terminal window: sudo /Library/PostgreSQL/9.X/uninstall-postgresql.app/Contents/MacOS/installbuilder.sh

C. If installed with Postgres Installer, do:

open /Library/PostgreSQL/9.X/uninstall-postgresql.app

Remove the PostgreSQL and data folders. The Wizard will notify you that these were not removed.

sudo rm -rf /Library/PostgreSQL

Remove the ini file:

sudo rm /etc/postgres-reg.ini

Remove the PostgreSQL user using System Preferences -> Users & Groups.

Unlock the settings panel by clicking on the padlock and entering your password. Select the PostgreSQL user and click on the minus button. Restore your shared memory settings: sudo rm /etc/sysctl.conf

Prashant Pokhriyal
  • 3,727
  • 4
  • 28
  • 40
  • doing `sudo open uninstall-postgresql.app` gives me `The application cannot be opened for an unexpected reason, error=Error Domain=NSOSStatusErrorDomain Code=-10827 "kLSNoExecutableErr: The executable is missing" UserInfo={_LSLine=3665, _LSFunction=_LSOpenStuffCallLocal}`. Any way to fix this? – edrichhans Jan 28 '21 at 04:36
19

I was not able to uninstall PostgreSQL 9.0.8. But I finally found this. (I installed Postgres using homebrew)

brew list

Look for the correct folder name. Something like.

postgresql9

Once you find the correct name do:

brew uninstall postgresql9

That should uninstall it.

Fernando Munoz
  • 4,541
  • 2
  • 18
  • 16
12

Uninstallation :

sudo /Library/PostgreSQL/9.6/uninstall-postgresql.app/Contents/MacOS/installbuilder.sh

Removing the data file :

sudo rm -rf /Library/PostgreSQL

Removing the configs :

sudo rm /etc/postgres-reg.ini

And thats it.

Dhammika
  • 441
  • 4
  • 10
6

open terminal and type the below command and hit enter

sudo /Library/PostgreSQL/9.X/uninstall-postgresql.app/Contents/MacOS/installbuilder.sh
Trinadh Koya
  • 1,089
  • 15
  • 19
3

Incase you have multiple versions of Postgres installed on your machine. You can remove all via brew command as:

brew uninstall --force postgresql
elixir
  • 752
  • 1
  • 7
  • 25
2

If you installed using the graphical installer by BigSQL from the official postgres site and if you installed in the default location...

You can find your uninstaller in your home directory: /Users/<yourusername/PostGreSQL/uninstall/

1

Another avenue that hasn't been considered is that your postgres was installed by pgvm (Postgres Version Manager).

Uninstall with pgvm uninstall 9.0.3

ianrandmckenzie
  • 472
  • 3
  • 12