

usr/local/Cellar/postgresql/10.0/bin/postgres "-D" "/usr/local/var/postgres" $ pg_ctl -D /usr/local/var/postgres/ status => Successfully started `postgresql` (label: ) Start the new server: $ brew services start postgresql Move the new cluster into place: $ mv postgres.new postgres Use the appropriate old and new binary and cluster directory locations, if they're different from the ones I had. B /usr/local/Cellar/postgresql/10.0/bin/ \ Run the upgrade process: $ pg_upgrade -b /usr/local/Cellar/postgresql/9.6.5/bin/ \ Initialize a new cluster data dir: $ initdb /usr/local/var/postgres.new Move the old cluster data directory out of the way: $ mv /usr/local/var/postgres /usr/local/var/postgres.old For now keep the new version active as we'll be using commands from the new version to complete the upgrade. If you need to you can switch your binaries between the old and new versions with brew switch postgresql. Lrwxr-xr-x 1 stade admin 34 Oct 18 19:28 /usr/local/bin/psql ->. The default linked binaries, in /usr/local/bin now belong to the 10.0 installation, but the database directory has not yet been upgraded. You should see both your old installed version and version 10.0: $ ls -lĭrwxr-xr-x 12 stade admin 384 Oct 18 19:28 10.0ĭrwxr-xr-x 12 stade admin 384 Oct 1 12:48 9.6.5

Take a look in /usr/local/Cellar/postgresql. Or, if you don't want/need a background service you can just run: To have launchd start postgresql now and restart at login: `pg_upgrade` or `pg_dumpall` depending on your upgrade method.ĭo not run `brew cleanup postgresql` until you have performed the migration. You will need your previous PostgreSQL installation from brew to perform You'll see this message at the end of the upgrade process: To migrate existing data from a previous major version of PostgreSQL, see:
#Homebrew postgres data directory install#
Install the new version (the old version remains installed): $ brew update Stop the old server: $ brew services stop postgresql Take a backup of your databases just in case anything goes wrong, you can recreate the data: $ pg_dumpall | gzip > all_db.sql.gz At the time of this writing I was using macOS 10.30 High Sierra and Postgresql 9.6.5.
#Homebrew postgres data directory how to#
This post explains how to upgrade to the latest version of PostgreSQL on macOS using Homebrew. It comes with tremendous amount of new features likeĪ nice list, including explanations can be found on Robert Haas’ blog. On October 5th the PostgreSQL Global Development Group announced the release of PostgreSQL 10.
