我正在尝试使用以下设置在 pgadmin3 中注册新服务器:
Name: postgres
Host: localhost
Username: postgres
Password: <password which works for psql>
Service: empty or postgres
但是显示错误:
FATAL: Ident authentification failed for user "postgres"
我重启了 postgresql 服务,但没有用。
/var/lib/pgsql/data/pg_hba.conf 的内容:
# TYPE DATABASE USER CIDR-ADDRESS METHOD
# "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 ident
编辑:工具 -> 服务器配置 -> pg_hba.conf 变灰。
最佳答案
看起来 PgAdmin-III 可能默认通过 IPv6 连接,因此它使用与本地主机的 IPv6 地址相匹配的 ident
行,::1/128
.
如果你想使用密码验证,你可能想要:
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
我不确定为什么要将 unix 域套接字行设置为 trust
,但如果它只是一台开发机器,那可能没问题,所以保持不变。将其设置为 ident
(如果您希望 unix 用户必须与 Pg 用户相同)或 md5
(用于本地 unix 上的密码验证)确实安全得多套接字)。
如果 PgAdmin-III 没有编辑权限,您需要直接在文本编辑器中编辑 pg_hba.conf
。您可以通过 sudo
作为用户 postgres
运行 PgAdmin-III,但使用 nano
或类似命令更安全(并且可能更容易) -行文本编辑器修改pg_hba.conf
。
密码适用于 psql
因为 psql
除非另有说明,否则将通过 unix 域套接字连接,并且您已将其设置为 trust
。您可能会发现您可以为 psql
提供任何密码,它仍然可以工作,因为它从来没有被要求实际提供密码,它只是被自动信任。
关于postgresql - pgadmin3 : FATAL: Ident authentification failed for user "postgres",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12489036/