If you hit this problem after doing a brew upgrade
which upgraded postgres to a new major version (f.ex 9.3.0
to 9.4.0
or higher), then do this:
@dmitrygusev's fix from https://github.com/Homebrew/homebrew/issues/35240
Following official [Postgresql] migration guide helped:
brew switch postgres 9.3.5 # presuming you already installed 9.4.1 pg_dumpall > outputfile launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist mv /usr/local/var/postgres /usr/local/var/postgres.old brew switch postgres 9.4.1 initdb -D /usr/local/var/postgres psql -d postgres -f outputfile
That's all. Check if import went well, then delete backups:
rm outputfile rm -Rf /usr/local/var/postgres.old
The issue here is that on a major version upgrade of postgres, it's necessary to recreate/migrate your database. And possibly chown
directories or manually call initdb
.
See also: How to upgrade PostgreSQL from version 9.6 to version 10.1 without losing data?
Some other tips, that might come in handy, in case you're not using Homebrew:
Stop PG server manually:
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log stop
Start PG server manually:
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start