DEV Community

Cover image for How to install Postgres on OSX in 2K19 with 🍺
Louis Bertin
Louis Bertin

Posted on

How to install Postgres on OSX in 2K19 with 🍺

Prerequisites

  • You have to be on OSX 🍎
  • Homebrew installed as dependency manager 🍺

Story

This morning I was working on a project that I have to install Postgres. I was thinking to myself that it was a really easy thing and that it will take me 3 minutes (the time to run brew install postgres and go grab a cup of tea in the open space)

BUT, it wasn't the case and I'm just facing with a weird issue. That's why I'm writing this article, maybe this could help someone and save your time.

Install Postgres on OSX with Homebrew

  • First, you have to run this brew command line brew install postgres
  • Just verify that the installation is successful postgres --version

Now, you can run the command line to start Postgres pg_ctl -D /usr/local/var/postgres start
If it works, you're lucky! But if you have FATAL: database files are incompatible with server you're on the right post!

Postgres issue on startup

Solution

The solution was to run brew postgresql-upgrade-database to upgrade your database files to the 11 version. You can have old database files who was initially created with the version 10 of Postgres. That's why you have an error.

And.. then?

Now you can rerun the command pg_ctl -D /usr/local/var/postgres start and it should work like a charm πŸŽ‰

Top comments (0)