从命令行使用Postgresql获取身份验证失败错误 [英] Getting authentication failed error with postgresql from command line
问题描述
当我尝试从这样的命令行登录
When i try to login from command line like this
psql -h dbserver -U testuser test
然后我收到此错误
psql: FATAL: Ident authentication failed for user "testuser"
这是我的
nano -w /var/lib/pgsql/data/pg_hba.conf
nano -w /var/lib/pgsql/data/pg_hba.conf
# TYPE DATABASE USER CIDR-ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all ident
# IPv4 local connections:
host all all 127.0.0.1/32 password
# IPv6 local connections:
host all all ::1/128 ident
host all all 192.168.0.1/24 password
推荐答案
您可以t用 psql
指定非默认用户使用 ident
身份验证时。您将不会以该用户身份运行 psql
,因此身份验证将失败。
You can't specify a non-default user with -U
in psql
when using ident
authentication. You won't be running psql
as that user, so auth will fail.
您必须使用 sudo -u testuser psql test
或更改 pg_hba.conf
以便进行身份验证(至少对于 testuser < db
和 test
上的/ code>使用 md5
密码认证,并为<$ c设置密码$ c> testuser ALTER USER ...密码
(如果还没有密码的话)。
You must either use sudo -u testuser psql test
or change pg_hba.conf
so that authentication (at least for testuser
on the db test
) uses md5
password authentication, and set a password for testuser
with ALTER USER ... PASSWORD
if they don't have one already.
这篇关于从命令行使用Postgresql获取身份验证失败错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!