更新时间:2021-12-08 08:33:47
对等身份验证表示它正在使用unix套接字并希望连接的Unix用户具有与PostgreSQL用户名相同的Unix用户名。
"Peer authentication" means that it's using a unix socket and expecting the connecting unix user to have the same unix username as the postgresql username.
由于您本地的Unix用户名是 funkdified
,而您尝试通过用户 goodsounds
通过Unix域套接字( local
)连接,而您的 pg_hba.conf
指定 peer
身份验证,Pg正确拒绝了您的连接尝试。
Since your local unix username is funkdified
and you're trying to connect as user goodsounds
over a unix domain socket (local
) connection where your pg_hba.conf
specifies peer
authentication, Pg correctly rejects your connection attempt.
这是使用unix套接字时许多安装的默认行为。
This is the default behaviour for many installs when using unix sockets.
您可以:
pg_hba.conf
使用 md5
密码身份验证代替 peer
身份验证来使用unix套接字( local
连接类型),因此Pg接受密码身份验证;或pg_hba.conf
to use md5
password authentication instead of peer
authentication for unix sockets (local
connection type) so Pg accepts password authentication; or请参见 pg_hba.conf 和其余的客户端文档的认证一章。
请注意,对 pg_hba.conf
的更改不会立即生效,必须重新启动或至少重新加载PostgreSQL才能重新读取 pg_hba.conf
。
Note that changes to pg_hba.conf
do not take effect immediately, you must restart or at least reload PostgreSQL to get it to reread pg_hba.conf
.
同样,如果您安装了多个PostgreSQL版本,则可能有一个版本的libpq和另一版本的服务器。在这种情况下,请确保libpq默认连接到的unix套接字的位置与服务器的 unix_socket_directories
相同,或使用(例如)覆盖它。连接字符串中的host = / tmp
。
Oh, also, if you have multiple PostgreSQL versions installed you might have a libpq from one version and a server from another. In this case make sure the location for the unix socket that libpq connects to by default is the same as the server's unix_socket_directories
or override it with (e.g.) host=/tmp
in your connection string.