Last Updated: December 21, 2016
·
10.03K
· kenjione

How to launch postgresql after upgrade

When I tried to start postgresql server after upgrade to OS X 10.10 Yosemite, I encountered with a next problem:

pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start

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

Okay, lets take a look into server logs:

$ cat /usr/local/var/postgres/server.log

FATAL: database files are incompatible with server
DETAIL: The data directory was initialized by PostgreSQL version 9.2, which is not compatible with this version 9.3.5.

So, we need to follow a few steps after upgrade postgresql:

1 $ launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist

2 $ mv /usr/local/var/postgres /usr/local/var/postgres92

3 $ brew update

4 $ brew upgrade postgresql

5 $ initdb /usr/local/var/postgres -E utf8

6 $ pg_upgrade -b /usr/local/Cellar/postgresql/9.2.3/bin -B /usr/local/Cellar/postgresql/9.3.5_1/bin -d /usr/local/var/postgres92 -D /usr/local/var/postgres

7 $ cp /usr/local/Cellar/postgresql/9.3.5_1/homebrew.mxcl.postgresql.plist ~/Library/LaunchAgents/

8 $ pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start

9 $ rm -rf /usr/local/var/postgres92

That's it.

1 Response
Add your response

Worked perfectly for me! Thanks

over 1 year ago ·