I have installed postgres and when I run psql
I am getting:
PostgreSQL error: Fatal: role "username" does not exist
and also when I run psql -h localhost -U postgres
I get:
PostgreSQL error: Fatal: role "postgres" does not exist
errors.
I have looked extensively at other questions here and in other locations such as: PostgreSQL error: Fatal: role "username" does not exist
psql: FATAL: role "postgres" does not exist
I can't make progress with any of the solutions.
I am on a Mac M1 with Sonoma. I installed postgres with homebrew and I am on version 14.
psql --version returns:
psql (PostgreSQL) 14.10 (Homebrew)
Is there anything else I can try seeing as I am encountering both errors.
export
returns:
HOME=/Users/username
HOMEBREW_CELLAR=/opt/homebrew/Cellar
HOMEBREW_PREFIX=/opt/homebrew
HOMEBREW_REPOSITORY=/opt/homebrew
INFOPATH=/opt/homebrew/share/info:
LOGNAME=username
MANPATH=/opt/homebrew/share/man::
OLDPWD=/Users/username
PATH=/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin
PWD=/Users/username
SHELL=/bin/zsh
SHLVL=1
TERM=xterm-256color
USER=username
If I run /opt/homebrew/bin/createuser -s postgres (for example) there is no change.
`ps ax | grep postgres` returns:
50147 ?? S 0:00.08 /opt/homebrew/opt/postgresql@14/bin/postgres -D /opt/homebrew/var/postgresql@14
50149 ?? Ss 0:00.01 postgres: checkpointer
50150 ?? Ss 0:00.05 postgres: background writer
50151 ?? Ss 0:00.03 postgres: walwriter
50152 ?? Ss 0:00.06 postgres: autovacuum launcher
50153 ?? Ss 0:00.08 postgres: stats collector
50154 ?? Ss 0:00.00 postgres: logical replication launcher
51978 s002 S+ 0:00.00 grep postgres
psql postgres
returns
psql: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: FATAL: role "username" does not exist
psql -d postgres -U username
and psql -d postgres -U "username"
return:
psql: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: FATAL: role "username" does not exist
Stop the PostgreSQL server, start it in single-user mode as described in the documentation and query
pg_user
to find the names of the database users.