PostgreSQL on macOS in 2023
I have already wrote about installing the PostgreSQL on the macOS, but time has went and it was time again to install it. It is different machine under the finger tips now. And it is same hobby project that I need the database for now too.
I tried to follow my previous post to get things going, but things were changed.
First I tried to install the PostgreSQL like I had previously. But I was given the following message on the terminal:
❯ brew install postgres
Warning: No available formula with the name "postgres". Did you mean postgrest or postgis?
postgresql breaks existing databases on upgrade without human intervention.
See a more specific version to install with:
brew formulae | grep postgresql@
Okay, let's run the suggested command to see it then and see the results:
❯ brew formulae | grep postgresql@
And at the time of writing the newest available version of the PostgreSQL was
15.3, so let's install it.
brew install postgresql@15
That worked without a hitch, nice.
I also made some changes to my
.zshrc as I'm using ZSH.
PostgreSQL to PATH
I added the PostgreSQL to be available on the
When I tried to use the same aliases that I have used before I got the error:
pg_ctl: directory "/usr/local/var/postgres" does not exist
So, the folders were now in different place and I had to update the previously used aliases a little. Here are the aliases that I ended up with.
alias pgstart='pg_ctl -D /opt/homebrew/var/postgresql@15 -l /opt/homebrew/var/postgresql@15/server.log start'
alias pgstop='pg_ctl -D /opt/homebrew/var/postgresql@15 stop -s -m fast'
alias pglog='tail -f /opt/homebrew/var/postgresql@15/server.log'
When I tried to start the PostgreSQL, it did not start. I checked from the logs and there was the explanation:
FATAL: role "postgres" does not exist
Very well then, after brief pause of thinking; it logical that empty instance does not have any user I. So let's create one.
createuser -s postgres
And now it started nicely.
And to see the database visually it might be nice to have something. I'm going to try pgAdmin. It seems pretty big app and sloooow to start.
Previously I had the trial of the Postico in use, but did not end up it so much.