加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

postgresql – pgadmin3:致命:用户“postgres”的身份验证失败

发布时间:2020-12-13 16:03:21 所属栏目:百科 来源:网络整理
导读:我正在尝试使用以下设置在pgadmin3中注册新服务器: Name: postgresHost: localhostUsername: postgresPassword: password which works for psqlService: empty or postgres 但它显示错误: FATAL: Ident authentification failed for user "postgres" 我重
我正在尝试使用以下设置在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,因此它使用与localhost,:: 1/128的IPv6地址匹配的ident行.

如果要使用密码身份验证,您可能需要:

# IPv4 local connections:
host    all         all         127.0.0.1/32          md5
# IPv6 local connections:
host    all         all         ::1/128               md5

我不确定你为什么要将unix域套接字行设置为信任,但如果它只是一个开发机器,那可能就行了,所以保持不变.将它作为ident(如果你希望unix用户必须与Pg用户相同)或md5(用于本地unix套接字上的密码auth)真的更安全.

如果PgAdmin-III没有编辑权限,则需要在文本编辑器中直接编辑pg_hba.conf.您可以通过sudo运行PgAdmin-III作为用户postgres,但是使用nano或类似的命令行文本编辑器来修改pg_hba.conf更安全(也可能更容易).

密码适用于psql,因为除非另有说明,否则psql将通过unix域套接字连接,并且您可以设置为信任.你可能会发现你可以给psql任何密码并且它仍然可以工作,因为它永远不会被要求实际提供密码,它只是被自动信任.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读