Working with Heroku I recently wanted to pull the Heroku production DB to my local DB. Using pg:pull
I got the following error message:
pg_dump: aborting because of server version mismatch
because Heroku uses PostgreSQL 9.4 and my local version was 9.3.
So I had to update my local DB; this is what I did:
1) shut down db and remove launch agent plists:
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
rm ~/Library/LaunchAgents/homebrew.mxcl.postgresql*
2) remove links to old binaries, install new version (links automatically):
brew unlink postgresql93
brew install postgres
Note that I do not yet uninstall the old binaries, we need them to run pg_update later!
3) Link the new launch agent plist
ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents
4) create a new empty cluster with the same locale as the old one:
initdb /usr/local/var/postgres9.4 --locale=en_US.UTF-8
5) run the upgrade script (using the binary of the new version)
pg_upgrade -v \
-d /usr/local/var/postgres \
-D /usr/local/var/postgres9.4 \
-b /usr/local/Cellar/postgresql93/9.3.5/bin \
-B /usr/local/Cellar/postgresql/9.4.5_2/bin
6) start new server and uninstall the old version:
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
brew uninstall postgresql93
7) optional: re-install the pg rem for my ruby app
gem uninstall pg
bundle
Hope this helps somebody!