Running multiple PostgreSQL versions on MacOS
It’s possible to run multiple versions of PostgreSQL using excellent Postgres.app. It’s very good solution as long as you don’t need older Postgres versions (
Postgres.app allows to run up to 4 last major versions).
This is an alternative solution which allows to run older versions and easily switch between them.
Start with tapping
brew tap petere/postgresql
Now you can install multiple versions:
brew install postgresql-9.3 brew install postgresql-9.6
I recommend to install
postgresql-common which provides special wrapper scripts for running managing the clusters.
Before starting the database, you need to create a cluster:
pg_createcluster 9.6 main
9.6 is postgres version and
main is the name of the cluster to use. After that you can use
psql to connected to newly created cluster:
psql --cluster 9.6/main -d postgres
pg_lsclusterslist all clusters
pg_dropclusterremove a cluster
pg_ctlcluster 9.6 main startstart a cluster
pg_ctlcluster 9.6 main stopstop a cluster
pg_ctlcluster 9.6 main statuscheck claster’s status
NOTE: In all above examples
9.6 is a PostgreSQL version and
main is the name of the cluster to use.