29

Upgraded 10.6 from 10.5 and now postgres 8.1 is whacked. To make things worse I tried installing 8.4 which I'm pretty sure just made things ten times worse. Anyhow, the exception I'm getting when I try to fire postgres up and just createuser is this:

createuser: could not connect to database postgres: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/tmp/.s.PGSQL.5432"?

HOW do I fully get rid of postgres on my Mac so I can do a do-over?

Thanks

wgpubs
  • 8,131
  • 15
  • 62
  • 109
  • How did you install Postgresql, via source or some package install method? – Kuberchaun Apr 26 '10 at 17:03
  • I don't remember how I originally installed it. Wasn't from source. I think it was the install from here: http://www.postgresqlformac.com/ – wgpubs Apr 26 '10 at 17:12

4 Answers4

63

The problem was with the PostgreSQL account sitting on my machine.

I removed the account and proceeded with the uninstall using the instructions here:

Automatic Uninstall:

In the installation directory, there will be a uninstall-postgresql.app file. Executing (double clicking) that will uninstall the PostgreSQL installation.

Manual Uninstall:

  1. Stop the server:

    sudo /sbin/SystemStarter stop postgresql-8.3
    
  2. Remove menu shortcuts:

    sudo rm -rf /Applications/PostgreSQL 8.3
    
  3. Remove the ini file:

    sudo rm -rf /etc/postgres-reg.ini
    
  4. Removing Startup Items:

    sudo rm -rf /Library/StartupItems/postgresql-8.3
    
  5. Remove the data and installed files:

    sudo rm -rf /Library/PostgreSQL/8.3
    
  6. Delete the user postgres:

    sudo dscl . delete /users/postgres 
    
the Tin Man
  • 158,662
  • 42
  • 215
  • 303
wgpubs
  • 8,131
  • 15
  • 62
  • 109
9

I can add this tiny command to the answer too:

rm /usr/bin/psql

Remove executable psql alias.

Amir Latifi
  • 798
  • 8
  • 15
  • 2
    This is closer to the answer than the above. Apple ships with postgres binaries preinstalled (as of Lion, 10.7). There will *not* be the uninstaller that the chosen answer mentions. – Chris Jun 21 '12 at 19:06
  • well the question clearly states that its not lion but snow-leopard (10.6), but nevermind, the chosen answer works perfectly. – zuloo May 18 '13 at 22:55
  • explain what, the line and comment stands on its own. Its an extra line for the answer above or would you rather the entire answer was repeated? – Stevetech Jul 23 '13 at 07:20
  • You will also need to do get rid of all the /usr/bin/pg_* executables (like pg_dump, pg_restore, etc.) – rootsmith Oct 07 '13 at 21:18
  • I think better is to add postgres installation /bin path to the system $PATH instead of removing parts of system. After that you will use versions of psql pg_* same as postgresql server. – cintrzyk Nov 17 '13 at 10:11
  • I get `rm: /usr/bin/psql: Permission denied` when I try this solution. Is there a way around it? – Wilhelm Jul 15 '14 at 16:51
2

If you have newer Postgres and/or OSX/macOS version, you can check this answer.

Community
  • 1
  • 1
Robert Lujo
  • 15,383
  • 5
  • 56
  • 73
0

SINCE I couldn't run/find installbuilder.sh using the following command...

me@myMac:/Library/PostgreSQL/14/uninstall-postgresql.app/Contents/MacOS$ installbuilder.sh  
-bash: installbuilder.sh: command not found  

...I went on to try the steps below:

  1. me@myMac:/Library/PostgreSQL/14/uninstall-postgresql.app/Contents/MacOS$ ls -la  
    total 3112
    drwxr-xr-x  5 root  daemon      160 Sep 23 10:48 ./
    drwxr-xr-x  5 root  daemon      160 Sep 23 09:18 ../
    -rwxr-xr-x  1 root  daemon      673 Sep 23 10:48 installbuilder.sh*
    -rwxr-xr-x  1 root  daemon  1449456 Sep 23 10:07 osx-x86_64*
    -rwxr-xr-x  1 root  daemon   135216 Jul 14 11:21 uninstall-postgresql*  
    
  2. me@myMac:/Library/PostgreSQL/14/uninstall-postgresql.app/Contents/MacOS$ ./installbuilder.sh
    Unable to initialize installer  
    
  3. me@myMac:/Library/PostgreSQL/14/uninstall-postgresql.app/Contents/MacOS$ ./uninstall-postgresql  
    Usage: ./uninstall-postgresql installerName [args ...]
    
  4. me@myMac:/Library/PostgreSQL/14/uninstall-postgresql.app/Contents/MacOS$ ./uninstall-postgresql osx-x86_64
    

and VOILA!!!

  1. This launched the uninstall GUI

  2. Choose UNINSTALL ALL / REMOVE ENTIRE INSTALLATION enter image description here

  3. The uninstaller will do its thing and then prompt you with this: enter image description here

  4. At this point you'll want to follow the steps provided in this PREVIOUS StackOverflow ANSWER - steps 3 through 6 of @user1181328's answer. I'll list them here for convenience:

  1. Remove the PostgreSQL and data folders. The Wizard will notify you that these were not removed.
    sudo rm -rf /Library/PostgreSQL

  2. Remove the ini file:
    sudo rm /etc/postgres-reg.ini

  3. 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.
  4. 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.

Flak DiNenno
  • 2,193
  • 4
  • 30
  • 57