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/homebrew.mxcl.postgresql@14.plist
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?
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.