Macos psql:致命:角色“;vimarshchaturvedi“;不存在。Postgres.app安装

Macos psql:致命:角色“;vimarshchaturvedi“;不存在。Postgres.app安装,macos,postgresql,authentication,postgresql-9.6,Macos,Postgresql,Authentication,Postgresql 9.6,我正在开发OS X El Capitan版本10.11.3 我下载了Postgres应用程序并运行了该应用程序 顶部的大象图标显示版本9.6.1.0(9.6.1.0) 当我点击“OpenPSQL”时,我在终端上得到以下输出 $ '/Applications/Postgres.app/Contents/Versions/9.6/bin'/psql -p5432 psql: FATAL: role <username> does not exist 再搜索一点后,我运行了以下命令:

我正在开发OS X El Capitan版本10.11.3 我下载了Postgres应用程序并运行了该应用程序

顶部的大象图标显示版本9.6.1.0(9.6.1.0)

当我点击“OpenPSQL”时,我在终端上得到以下输出

$ '/Applications/Postgres.app/Contents/Versions/9.6/bin'/psql -p5432
psql: FATAL:  role <username> does not exist
再搜索一点后,我运行了以下命令:

psql -h localhost -U postgres
postgres=# 

博士后的外壳打开了。有人能解释发生了什么吗?

在没有任何给定用户名(
-U…
)的情况下启动psql会尝试使用与当前操作系统用户同名的db用户登录。显然,尚未创建DB user

使用每个DB集群创建的默认超级用户名为
postgres
。不要将其与RDBMS或名为
postgres
的系统数据库的名称混淆

您可以使用user
postgres
登录并且没有PW,这表明了两件事:

  • 用户的postgres存在(duh)
  • 通过
    .pgpass
    文件或
    pg_hba.conf
    中的一种身份验证方法
    peer
    ident
    trust
    将其设置为无密码访问<代码>同级最有可能
  • 如果是,作为外壳的快速修复:

    createuser -h localhost -U postgres vimarshchaturvedi
    
    vimarshchaturvedi
    显然是您的操作系统用户名

    登录后,您可以检查退出的登录角色(=用户):

    psql -h localhost -U postgres
    postgres=# 
    
    createuser -h localhost -U postgres vimarshchaturvedi
    
    SELECT rolname FROM pg_roles;