gpt4 book ai didi

postgresql - psql : error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL: Peer authentication failed for user "postgres" (Ubuntu)

转载 作者:行者123 更新时间:2023-12-04 18:24:33 24 4
gpt4 key购买 nike

当我尝试打开 psql使用此命令:

psql -U postgres
我收到此错误:
psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL:  Peer authentication failed for user "postgres"
但是当我使用它时它连接成功:
sudo -u postgres psql
有人可以解释发生了什么以及如何诊断/解决这个问题吗?我的 pg_hba.conf包含以下内容:

# Database administrative login by Unix domain socket
local all postgres peer

# TYPE DATABASE USER ADDRESS METHOD

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

最佳答案

Peer authentication表示只有当数据库用户名与操作系统用户名相同时才允许连接。
所以如果你运行 psql -U postgres作为操作系统用户rootjimmy ,它不会工作。
您可以指定 mapping pg_ident.conf 中的操作系统用户和数据库用户之间的.

关于postgresql - psql : error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL: Peer authentication failed for user "postgres" (Ubuntu),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69676009/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com