Home > Mobile >  psql cannot start on Mac M1 Monterey
psql cannot start on Mac M1 Monterey

Time:09-30

On my new Mac M1 (Monterey), I tried to install Postgres with brew:

brew install postgresql@14

After installation is completed, I can see that the service is running:

brew services list
> postgresql@14 started johndoe ~/Library/LaunchAgents/[email protected]

Problem is when I try to issue the psql command I get the following:

psql: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: FATAL:  role "johndoe" does not exist

I tried to uninstall postgres and reinstall it with brew but the same thing occurs. Can someone help?

CodePudding user response:

You should create the database user johndoe by

createuser -Upostgres -d johndoe

first. The -d flag allows the new user to create new databases. This can be done by

createdb -Ujohndoe mydb

After that you can connect to the new database as user johndoe by

psql -Ujohndoe -dmydb
  • Related