Skip to content

Instantly share code, notes, and snippets.

@hakjoon
Created August 2, 2017 17:33
Show Gist options
  • Save hakjoon/ba76aa649e4b5e1b6de2c9522da9ece8 to your computer and use it in GitHub Desktop.
Save hakjoon/ba76aa649e4b5e1b6de2c9522da9ece8 to your computer and use it in GitHub Desktop.
How to upgrade Homebrew PostgreSQL DB
# You can see what the old version you have is by looking at
# /usr/local/var/postgres/PG_VERSION
brew services stop postgresql
cp -r /usr/local/var/postgres /usr/local/var/postgres_bak #backup db just in case
mv /usr/local/var/postgres /usr/local/var/postgres<OLD_VERSION> # move it form default location
initdb /usr/local/var/postgres -E utf8 # create new DB in default location
pg_upgrade \
-b /usr/local/Cellar/postgresql/<OLD_VERSION>/bin/ \
-B /usr/local/Cellar/postgresql/<NEW_VERSION>/bin/ \
-d /usr/local/var/postgres<OLD_VERSION> \
-D /usr/local/var/postgres
pg_ctl -D /usr/local/var/postgres start # see if it worked
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment