0

我知道这个问题之前已经被问过好几次了,但我能找到的所有答案都告诉你在pg_hba.conf文件中添加如下一行:

host all all 127.0.0.1/32 md5

所以我的pg_hba.conf文件现在看起来像这样:

# TYPE  DATABASE        USER            ADDRESS                 METHOD                                                                                                                                             

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

# I've added the following lines:
host    all             all              127.0.0.1/32           trust
host    all             all              ::1/128                trust
host    all             all              127.0.0.1/32           md5
host    all             all              ::1/128                md5
host    all             all              192.168.0.0/24         md5

我过去在 ubuntu 上设置了几个 postgresql 服务器,从来没有遇到过问题。但是,在 Fedora 上,我仍然收到以下错误消息:

FATAL: Ident authentication failed for user "postgres"

服务器在 Fedora 27 Workstation 上运行,postgresql 版本为9.6.8-1.fc27

4

1 回答 1

0

您的 localhost 中有两个身份验证规则pg_hba.conf,即 ..

host all  all  127.0.0.1/32  ident

host all  all  127.0.0.1/32  trust

我相信系统正在尝试验证这两个身份验证选项,从而使该trust选项被ident. 由于您最有可能尝试trust从 localhost 进行身份验证(基于您的文件),因此只需注释/删除以下行:

host all  all  127.0.0.1/32  ident

然后使用以下查询重新启动数据库或重新加载 conf 文件:

SELECT pg_reload_conf();
于 2018-04-30T11:22:12.113 回答