Tuesday, June 7, 2011

OSX 10.7 Lion / Postgres installation issue

Recently I tried to install PostgreSQL on OSX 10.7 Lion and failed with this:

Problem running post-install step. Installation may not complete correctly
The database cluster initialisation failed.

I looked into /Library/PostgreSQL/8.3 and everything seems to be there except the data directory. So open up System Preferences > Users & Groups and add a user postgres. Then as root:

cd /Library/PostgreSQL/8.3
mkdir data
chmod 700 data
chown postgres data
su postgres
./bin/initdb /Library/PostgreSQL/8.3/data
(Watch it go and then you can start your server via)

./bin/postgres -D /Library/PostgreSQL/8.3/data
./bin/pg_ctl start -D /Library/PostgreSQL/8.3/data/ (for daemon mode, pg_ctl --help has a full list of commands)

Now in a new tab try /Library/PostgreSQL/8.3/bin/psql -U postgres and all should connect.

One word of warning. If you are using just psql without the full path it will load the default Lion psql command and you'll get this error:

dyld: Library not loaded: /usr/lib/libpq.5.dylib
Referenced from: /usr/bin/psql
Reason: no suitable image found. Did find:
/usr/lib/libpq.5.dylib: no matching architecture in universal wrapper
/usr/lib/libpq.5.dylib: no matching architecture in universal wrapper
Trace/BPT trap: 5

So make sure when launching psql that you include full path to the installation directory.



luigi said...

thanks a lot, but when restart mac is impossible to restart database ..
you have solution?

Alaskan Tahto said...

I got it working like so.
Follow at your own risk! I don't know what deleting the postgres user does in the long run.

1. Delete the postgres user that is already on the system (sudo dscl . delete /Users/postgres)
2. Delete the group also (sudo dscl . delete /Groups/postgres)
3. Make postgres user yourself through System preferences -> Users & Groups
4. Install normally with the installer

akil said...

This helped a lot .. Thank you!

Boris Cosic said...

Hi Luigi,
What is the exact error you get when you try and start Postgresql. Deleting the postgres user might do the job but I would be careful with that seeing how entire Lion now uses Postgres.

KMow said...

Thanks for this - I was truly stuck. All that stuffing around with the postgres user in the terminal - and I just needed it in the Preferences...

Post a Comment