Updating PostgreSQL with Homebrew on macOS Big Sur

I recently updated my install of PostgreSQL to v14 with Homebrew, and thought this small tutorial might help others. And it will obviously help me when it comes time to update again!


If you’re running macOS and are doing any kind of development work, and aren’t using Homebrew - you really should take a look. It’s a package manager which allows for quick and easy installation and updating of many common packages. It’s super easy to install:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Installing PostgreSQL

Just like Homebrew itself, installing packages is super easy. For postgres, it’s like so:

brew install postgresql

It really couldn’t be any easier.

Updating PostgreSQL

This is also easy to update, however migrating your databases to a new major update takes a little extra work. Running the following command will update all your packages:

brew update && brew upgrade

To only update PostgreSQL:

brew upgrade postgresql

Now to migrate your databases using the handy upgrade script:

brew services stop postgresql
brew postgresql-upgrade-database
brew services start postgresql

And once you check everything is in order, remove the old databases like so:

rm -rf /usr/local/var/postgres.old

That’s it! you should now be rocking the latest version of PostgreSQL. 👍