【问题标题】:postgresql: ident authentication failed on fedorapostgresql:在 Fedora 上的身份验证失败
【发布时间】:2018-04-30 10:32:57
【问题描述】:

我知道这个问题之前已经被问过好几次了,但我能找到的所有答案都告诉你在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

【问题讨论】:

  • 嘿,你重新加载了conf文件吗? select pg_reload_conf(); 我的意思是,如果你负担不起重启数据库系统的费用。
  • @JimJones 我做了几次systemctl restart postgresql
  • 只是为了测试,如果你把ident改成trust,你能成功连接吗?
  • 只评论那一行host all all 127.0.0.1/32 ident 并保持原样host all all 127.0.0.1/32 trust
  • @JimJones 谢谢!这似乎是诀窍。为什么我不能同时启用identtrust

标签: postgresql fedora postgresql-9.6 fedora-27


【解决方案1】:

你的pg_hba.conf中有两个localhost的认证规则,即..

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();

【讨论】:

    猜你喜欢
    • 2015-06-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-09
    • 1970-01-01
    • 1970-01-01
    • 2014-01-24
    相关资源
    最近更新 更多