How can I remove Postgres completely from my Mac?

15,221

Solution 1

It looks like you just deleted a few files in Finder.

Assuming you used the installer from here, you need to follow the instructions in the guide about uninstalling:

Uninstallation

If you need to uninstall PostgreSQL, you can run the uninstaller that is created during the installation process at any time. Note that the uninstaller will never remove your data directory, or the service user account. You can find the uninstaller in the installation directory, and can run it as you ran the installer. No command line options are generally required. On Windows, you can also run the uninstaller from the Add/Remove Programs control panel applet.

In other words, just run the uninstaller installed with the rest of the program.

Solution 2

After running any uninstallers, the following should help you find any leftover SQL config or setup files in your Library directory (a common source of odd reinstallation behavior)

find ~/Library | grep sql

If there's anything there that looks like it's part of a PostgreSQL installation, deleting those before reinstalling may help. Sometimes there are hidden folder buried deeper down.

Also, ls -l /usr/bin/psql should expose any symlinks, if there are any, in the case that the psql application is housed in a different directory.

Share:
15,221

Related videos on Youtube

Christos Hayward
Author by

Christos Hayward

Jonathan Hayward is a recovering geek. He holds master's degrees bridging math and computer science (UIUC) and philosophy and theology (Cambridge), and is considered to be in the profoundly gifted range. He is presently learning Node and Russian. Read full biography—it's interesting.

Updated on September 18, 2022

Comments

  • Christos Hayward
    Christos Hayward almost 2 years

    I have been experiencing spooky behavior with Postgres after using the Mac installer for Postgres. There seems to be an existing half-baked Postgres installation that was already there and remains there after I deleted the Mac GUI installer version from /Applications and /Library. Part of the spooky behavior included being unable after repeated poking and prodding to get a particular user to authenticate with its behavior--but this makes sense if I had two parallel Postgres databases, one for which I was (successfully) setting the user with a particular password, and one which did not have this database set. Now that that version is uninstalled, I have a number of Postgres binaries that crash or give errors if I try to use them:

    $ psql
    dyld: Library not loaded: /usr/lib/libpq.5.dylib
      Referenced from: /usr/bin/psql
      Reason: image not found
    Trace/BPT trap: 5
    $
    

    I have not used MacPorts, Fink, or other Unix installers other than Homebrew in the life of this Mac. Homebrew disclaims ownership of a Postgres installation:

    # ls /usr/local/Cellar | grep -i postgres
    # 
    

    So however installed, I have a broken Postgres installation that I would like to wipe completely.

    How can I completely wipe Postgres from my system so I can install it with the installer and have one Postgres installation, instead of a spooky one and a half installations?

    • HikeMike
      HikeMike over 11 years
      "Now that that version is uninstalled" -- how did you uninstall it?
    • Christos Hayward
      Christos Hayward over 11 years
      I deleted the Postgres folders from /Applications and /Library (as stated above).
    • HikeMike
      HikeMike over 11 years
      I suggest you reinstall it, them uninstall it properly as described in my answer.
    • Basil Bourque
      Basil Bourque about 6 years
  • Christos Hayward
    Christos Hayward over 11 years
    Thank you. I have reinstalled and uninstalled with the installer, and am back to square one: $ psql dyld: Library not loaded: /usr/lib/libpq.5.dylib Referenced from: /usr/bin/psql Reason: image not found Trace/BPT trap: 5
  • Aman Alam
    Aman Alam over 5 years
    The link you provided for the un-installation guide, is broken