Sheri Tibbs
Sheri Tibbs

Reputation: 133

Cannot install postgres with brew. Get "FATAL: role "postgres" does not exist" no matter what command I try

I've tried to install postgres 13.1 on my Mac using homebrew. (Also tried versions 11 & 12 which at one time were installed on this Mac, but encountering same error with those versions now). Am using notes I took from previous installs & of course google/stackoverflow. Tried many things/many times, but always, if I run psql, createuser, createdb (any postgres command), it responds with:

FATAL: role "postgres" does not exist

Also tried just creating a postgres user on my Mac to run install from that account; no luck.

Also tried postgresql install from the enterprisedb.com site. That worked, but seems klunky & seems to rely on .sh scripts. Interestingly, got the 'role postgres does not exist' error after the edb install too, but noticed if I just entered 'postgres' twice on the command line it worked. Example:

/Library/PostgreSQL/13/bin/psql -h localhost -p 5432 -U postgres postgres

This trick doesn't work tho with the brew install.

Understand I need to create the postgres role, but I can't find a command to do this that doesn't complain that the role doesn't already exist.

Any help would be so so appreciated!

link to screenshot

Upvotes: 3

Views: 2948

Answers (3)

Steven Anderson
Steven Anderson

Reputation: 465

This document solved it for me: https://enrq.me/dev/2021/01/13/fix-role-postgres-does-not-exist/

The gist: run createuser -s postgres -U <os-username>

Upvotes: 1

Sheri Tibbs
Sheri Tibbs

Reputation: 133

Most sites documenting postgres install with homebrew said to use commands like:

psql postgres or createuser postgres

Those didn't work for me, but this did:

psql -d postgres -U <myUserName>

Attaching a screenshot to try to summarize the install experience & what worked: screenshot

Upvotes: 4

vyruss
vyruss

Reputation: 51

Can you try:

/Library/PostgreSQL/13/bin/psql

and then:

CREATE USER postgres SUPERUSER;

?

Upvotes: 0

Related Questions