如何使用psql作为postgres(要求输入密码,但我没有密码)?

时间:2018-01-08 13:49:28

标签: macos postgresql psql

我已经使用HomeBrew安装了Postgres,我尝试在其中创建一个新用户。

我尝试使用psql在Postgres中创建一个新用户和数据库,所以首先我尝试使用sudo -u postgres psql打开它,但它会提示我输入密码。据我所知,默认情况下该用户不应该有密码。

我也尝试编辑我的pg_hba.conf,但这对我来说似乎也很好:

  # "local" is for Unix domain socket connections only
  local   all             all                                     trust
  # IPv4 local connections:
  host    all             all             127.0.0.1/32            trust
  # IPv6 local connections:
  host    all             all             ::1/128                 trust
  # Allow replication connections from localhost, by a user with the
  # replication privilege.
  local   replication     all                                     trust
  host    replication     all             127.0.0.1/32            trust
  host    replication     all             ::1/128                 trust

为什么它会一直提示我一个密码(如果有密码应该是什么)?如果我只是尝试运行psql使用我当前的系统用户而不是postgres来登录,然后提供我当前用户的密码,那也不起作用(我是顺便说一句,在macOS上。

0 个答案:

没有答案
相关问题