How to upgrade PostgreSQL to 11.4 from 10 on MacOS

Deep Shah
2 min readOct 31, 2019

--

I recently updated my PostgreSQL to version 11.4 from 10.0. After the upgrade, I realised that I wasn’t able to start my PostgreSQL server. It kept giving me the following error:

The data directory was initialized by PostgreSQL version 10.0, which is not compatible with this version 11.4.

I had to follow bunch of steps to get back my old databases to work with PostgreSQL 11.4. This post is an attempt to document those steps for future reference.

The Solution

Install the older version of PostgreSQL using the following command

Output would be very similar to these messages

Unlink the newly installed older version of PostgreSQL. Brew will spit out the message confirming that the unlinking was successful.

Link the latest version of PostgreSQL. As before, brew will spit out the message stating that the linking was successful.

Move the data directory from default location to another location

Use initdb to initialise a new and empty data directory.

Output might look somewhat like this

Copy over the timezone and timezonesets directory to /usr/local/share/postgresql10

Upgrade the data directory using the following command

It will do bunch of things and might spit out messages like these

Moment of truth, start the PostgreSQL server

If everything goes through fine, you should see a message that states that PostgreSQL server was started successfully.

Cleanup steps

Thats about it! We have successfully upgraded PostgreSQL to 11.4 from 10.

Originally published at http://www.gitshah.com.

--

--

No responses yet