Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Upgrade PostgreSQL 9.5.5 to 9.6.1 using Homebrew (macOS)
After automatically updating Postgres to 9.6.1 via Homebrew, the pg_ctl start command didn't work.
The error was something like "database files are incompatible with server".
Database files have to be updated before starting the server, here are the steps that had to be followed:
# need to have both 9.6.1 and latest 9.5.x installed, and keep 9.6.1 as default
brew unlink postgresql
brew install postgresql95
brew unlink postgresql95
brew link postgresql
# move 9.5.x db files to another directory
mv /usr/local/var/postgres /usr/local/var/postgres95
# init new database using 9.6.1
initdb /usr/local/var/postgres -E utf8
# make timezonesets directory available for 9.5.x installation
mkdir /usr/local/share/postgresql95
cp -r /usr/local/share/postgresql/timezonesets /usr/local/share/postgresql95
# finally the actual upgrade
# -b is the old binary dir, -B is the new binary dir
# -d is the old data dir, -D is the new data dir
pg_upgrade -b /usr/local/Cellar/postgresql95/9.5.5/bin -B /usr/local/Cellar/postgresql/9.6.1/bin -d /usr/local/var/postgres95 -D /usr/local/var/postgres
# start 9.6.1 to check that upgrade works
pg_ctl start -D /usr/local/var/postgres
# cleanup if upgrade was successful
brew uninstall postgresql95
rm -rf /usr/local/var/postgres95
rm -rf /usr/local/share/postgresql95
@golmansax

This comment has been minimized.

Copy link

golmansax commented Nov 24, 2016

@giannisp Thanks for posting this! One other thing I had to do was copy over the timezone directory: cp -r /usr/local/share/postgresql/timezone /usr/local/share/postgresql95.

@devdude

This comment has been minimized.

Copy link

devdude commented Jan 13, 2017

Thank you @giannisp for this gist. FYI, I had to copy over the timezone dir as well, just like @golmansax mentioned.

@jmercedes

This comment has been minimized.

Copy link

jmercedes commented Apr 4, 2017

Thank you very much, this issue was driving me crazy.

@dantormey

This comment has been minimized.

Copy link

dantormey commented Jun 1, 2017

Thank you, worked like a charm for me.

@giannisp

This comment has been minimized.

Copy link
Owner Author

giannisp commented Oct 18, 2017

Version 10.0 has just been released today, so here is an updated gist for 9.6.5 => 10.0 migration:
https://gist.github.com/giannisp/ebaca117ac9e44231421f04e7796d5ca

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.