PostgreSQL:pg_hba.conf 中的 MD5 身份验证给我致命错误:用户 "postgres" 的对等身份验证失败

PostgreSQL: MD5 Authentication in pg_hba.conf gives me FATAL: Peer authentication failed for user "postgres"

我是 运行 Ubuntu 14.04 并安装了 PostgreSQL 9.3。 将 /etc/postgresql/9.3/main/pg_hba.conf 编辑为:

# "local" is for Unix domain socket connections only
local   all             all                                     md5
# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
# IPv6 local connections:
host    all             all             ::1/128                 md5

我重新启动了服务器,现在我想以 postgres:

的身份登录到 postgres
victor@workstation:~$ psql -U postgres
psql: FATAL:  Peer authentication failed for user "postgres"

postgres 不应该提示我输入密码,因为我已将其身份验证方法设置为 MD5 ?

我知道如果我添加 -h localhost 它会起作用。

不添加此标志会导致 psql 使用对等身份验证吗?

你必须在这些上面再添加 local ... peer 行。错误 Peer authentication failed 来自 服务器 ,它是选择身份验证方法的服务器。

其他可能性是:

  • 实际上并没有重启服务器
  • 如果系统上有多个 PostgreSQL 实例,则编辑了错误的 pg_hba.conf 文件。

1) 从您的终端打开 -> /etc/phppgadmin -> config.inc.php。

2) 找到下面的行并将其更改为 False。

$conf['extra_login_security'] = true; to $conf['extra_login_security'] = false;

3) 更改重启后 Server.it 将解决您的问题。

/etc/init.d/httpd restart