3

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

1
  • which OS user owns the config file, and/or the data files? Try using that name as the existing database role. Commented Dec 18, 2020 at 3:15

3 Answers 3

4

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

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you, this answer worked for me for PG 14.
1

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>

Comments

0

Can you try:

/Library/PostgreSQL/13/bin/psql

and then:

CREATE USER postgres SUPERUSER;

?

2 Comments

Thank you. Tried /Library/PostgreSQL/13/bin/psql but it returned: -bash: /Library/PostgreSQL/13/bin/psql: No such file or directory. But I think I solved my problem. Sites I've found documenting how to install postgres with homebrew say to use command: psql postgres but it seems to need to be psql -d postgres -U <myUserName>. (Thank you very much for responding! This is my very first stackoverflow post.)
Glad you got it sorted.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.