Postgres:尝试使用不同的unix用户登录时身份验证失败

day*_*mer 5 postgresql login

我有一个用户hduser和用户postgres,

hduser:

hduser@master:/$ psql -Upostgres -W analytics
Password for user postgres: 
psql: FATAL:  Ident authentication failed for user "postgres"
hduser@master:/$ 
Run Code Online (Sandbox Code Playgroud)

postgres:

postgres@master:/opt/pentaho/biserver-ce$ psql -Upostgres -W analytics
Password for user postgres: 
psql (8.4.9)
Type "help" for help.

analytics=# 
Run Code Online (Sandbox Code Playgroud)

如何使用其他用户hduser或其他用户登录同一数据库?

谢谢

A.H*_*.H. 18

PostgreSQL的默认配置仅允许对数据库用户进行"本地"访问,这些用户与OS用户具有相同的名称."local"表示仅使用Unix-Domain套接字而没有任何IP流量.请参阅配置文件的文档,pg_hba.conf尤其是以"local"开头的行和身份验证方法"peer"或"ident".

另一方面,默认情况下,使用IP传输通道访问postgres,如果有密码,则使用密码.因此,这应该可以帮助普通用户.

foouser@host$ psql -U baruser -h 127.0.0.1 database
Run Code Online (Sandbox Code Playgroud)

坏消息是,DB超级用户postgres默认没有密码,因此您必须先设置密码.


dig*_*oel 0

您可以为 hduser设置.pgpass文件