Skip to content

Instantly share code, notes, and snippets.

@TaurusOlson
Last active February 7, 2016 12:58
Show Gist options
  • Save TaurusOlson/4cd6538bd67469a82f80 to your computer and use it in GitHub Desktop.
Save TaurusOlson/4cd6538bd67469a82f80 to your computer and use it in GitHub Desktop.
Upgrade PostgreSQL on Mac OS X

Upgrade PostgreSQL

This document briefly describes how to upgrade PostgreSQL from 9.4.5 to 9.5 and assumes the installation was done with Homebrew. Upgrades between other versions should be similar.

(original source: http://stackoverflow.com/a/27624397/63347)

Stop the server

pg_ctl stop -w -D /usr/local/var/postgres

Upgrade with homebrew

brew upgrade postgresql

Initialize a new 9.5 database

initdb /usr/local/var/postgres9.5 -E utf8

Run pg_upgrade

pg_upgrade -v \
-d /usr/local/var/postgres \
-D /usr/local/var/postgres9.5 \
-b /usr/local/Cellar/postgresql/9.4.5/bin/ \
-B /usr/local/Cellar/postgresql/9.5.0/bin/

Move new data into place

cd /usr/local/var
mv postgres postgres9.4
mv postgres9.5 postgres

Restart the server

pg_ctl start -D /usr/local/var/postgres -w -l /usr/local/var/postgres/postgres-server.log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment