2

I am trying to re-install Postgres via home-brew on Mac. I uninstalled Postgres, updated home-brew and ran the install command for brew install postgres

when I run brew services start postgresql

I get the below error message:

Bootstrap failed: 5: Input/output error Error: Failure while executing; /bin/launchctl bootstrap gui/501 /Users/edac/Library/LaunchAgents/homebrew.mxcl.postgresql.plist exited with 5.

When I try to start a server through the Postgres app I receive this message:

Required PostgreSQL version not installed

The data directory was initialized with PostgreSQL 13.

This copy of Postgres.app includes the following PostgreSQL versions: 14.

Please try downloading a different release of Postgres.app.

originally when I installed Postgres all I did was run the home-brew cli and install the app and I was good to go. Not sure what's gone wrong.

1
8

The issue is the previous install of postgres was postgres 13, and it created a database under:

/usr/local/var/postgres

which is now incompatible with the version of postgres you're installing, which is version 14.

First question: Do you care about your data?

If not then you can simply delete that folder and attempt to restart the service.

to delete and restart the service do:

rm -rf /usr/local/var/postgres
initdb --locale=C -E UTF8 /usr/local/var/postgres
brew services start postgresql

Otherwise you need to install postgresql@13, and perform a database migration, which can be summed up as follows:

install older postgres, make sure it's stopped

brew install postgresql@13
brew services stop postgresql@13
brew services stop postgres

delete the postgres 13 database created by the installation of postgresql@13

rm -rf /usr/local/var/postgresql@13

move old data to compatible driver folder:

mv /usr/local/var/postgres /usr/local/var/postgresql@13

Now we do the upgrade. First cd to the database folder

cd /usr/local/var

Construct a new blank database, with locale C, encoding of UTF8

initdb --locale=C -E UTF8 -D postgres

Perform the upgrade itself:

pg_upgrade -d postgresql@13 -D postgres -b /usr/local/Cellar/postgresql@13/13.4/bin -B /usr/local/Cellar/postgresql/14.0/bin -v

This should end in success. If it doesn't (e.g. locale/encoding is wrong), then chose the locale and encoding that matches the database.

Finally restart the postgres service:

brew services start postgresql
3

The problem is really what @Petesh said. But, the resolution for me was simpler.

When you upgrade your postgresql with brew, it logs a success message. One thing registered will be:

To migrate existing data from a previous major version of PostgreSQL run:
  brew postgresql-upgrade-database

So the only thing you need to do is to run the command below:

brew postgresql-upgrade-database

And of course you need to restart the service:

brew services restart postgresql

If you want to make sure it worked, you can run the start command too:

brew services start postgresql
1
  • cool - I didn't realize that there was a brew helper for this
    – Petesh
    Nov 2 at 21:33
0

It seems that the postgresql is already started before running the start command.

So do restart it instead of starting, by the following command:

brew services restart postgresql
0

I had this for Apache. To fix it, I unloaded the plist file. In your case

launchctl unload /Users/edac/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
launchctl load /Users/edac/Library/LaunchAgents/homebrew.mxcl.postgresql.plist

Then I re-ran the start services command and it worked.

brew services start postgresql

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .