Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Joseworks/f48ebd5a10bf5eb39386a601cd84fa39 to your computer and use it in GitHub Desktop.
Save Joseworks/f48ebd5a10bf5eb39386a601cd84fa39 to your computer and use it in GitHub Desktop.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment