psql无法在Mac M1+Monterey上启动



在我的新Mac M1(蒙特利(上,我尝试安装带有brew:的Postgres

brew install postgresql@14

安装完成后,我可以看到服务正在运行:

brew services list
> postgresql@14 started johndoe ~/Library/LaunchAgents/homebrew.mxcl.postgresql@14.plist

问题是,当我尝试发出psql命令时,我会得到以下信息:

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

我试着卸载postgres并用brew重新安装它,但同样的事情发生了。有人能帮忙吗?

您应该通过创建数据库用户johndoe

createuser -Upostgres -d johndoe

首先。-d标志允许新用户创建新的数据库。这可以通过完成

createdb -Ujohndoe mydb

之后,您可以通过以用户johndoe的身份连接到新数据库

psql -Ujohndoe -dmydb

最新更新