Forked from giannisp/gist:b53a76047b07751ed3ade3c1db1d2c51
Last active
August 2, 2017 10:59
-
-
Save willwright82/986d7893d98aab6632fc63740b6d06f1 to your computer and use it in GitHub Desktop.
Upgrade PostgreSQL 9.5.1 to 9.6.3 using Homebrew (macOS)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/postgresql/9.5.1/bin -B /usr/local/Cellar/postgresql/9.6.3/bin -d /usr/local/var/postgres95 -D /usr/local/var/postgres | |
# start 9.6.3 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