We will install PostgreSQL with PostGIS using Postgres.app.
If you have a working PostgreSQL database and no problems, consider keeping that. These instructions assume you have do not have a working database.
If you have an existing or broken installation:
- Stop the PostgreSQL servers.
- Copy your data directory to a safe temporary location and make a backup. I will assume ~/Desktop/postgres
- Remove the existing PostgreSQL installation.
Note that if you have (the remnant of) a brew installation, your data directory is probably /usr/local/var/postgres
.
Go to https://postgresapp.com and follow instructions. You now have a PostgreSQL server ready to roll. Embrace the black box. I prefer this over brew install postgis
, because that keeps breaking for me.
Start a new cluster of your choice. Instructions are at https://postgresapp.com.
You will need to create a database cluster of the same major version your previous installation was running. I will assume Postgres 12.
- Create a Postgres 12 cluster. We will assume the name
pg12
. - The default location is
~/Library/Application Support/Postgres/pg12
, that is fine. - Confirm the server starts.
- Stop the server.
- Copy your saved data directory over the newly created
~/Library/Application Support/Postgres/pg12
. Say yes to replacing whenever it is asked. - Start the server. It should work. If not, either start with a clean cluster or Google any errors.