Performing Upgrades on PostgreSQL

Step1: Stop current Postgres server:

launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist


Step2: Initialize a new 9.6 database:

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


Step3: run pg_upgrade:

pg_upgrade -v \
                  -d /usr/local/var/postgres \
                  -D /usr/local/var/postgres9.6 \
                  -b /usr/local/Cellar/postgresql/9.5.5/bin/ \
                  -B /usr/local/Cellar/postgresql/9.6.1/bin/

Step4: Move new data into place:

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

Step5: Restart Postgres:

launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist


Step6: Check /usr/local/var/postgres/server.log for details and to make sure the new server started properly.