2017-03-10 53 views
-2

当你试图连接到Postgres的:Centos的Postgres的连接

# psql -h localhost dgrt postgres 
I get an error: 
#User "postgres" has not passed authentication (Ident) 

配置我的文件 的postgresql.conf:

listen_addresses = '*' 

的pg_hba.conf:

#Allow replication connections from localhost, by a user with the 
#replication privilege. 

host all    all    127.0.0.1/32   ident 
+0

#UPDATE: 版本: CentOS 6的 PostgreSQL的9.3 – smilexcasper

+0

你可能运行不Postgres的。当你使用'ident'作为本地主机时,使用'peer' - 这意味着你的os用户应该匹配postgres,所以要作为postgres登录到db你必须是postgres在操作系统 –

+0

#UPDATE 2: 我需要连接而不是本地服务器,但远程服务器 #psql -h 10.10.10.2 dgrt postgres – smilexcasper

回答

1

随着ident AUTH您需要以正确的操作系统用户身份启动该命令,即数据库用户名必须匹配本地主机上的操作系统用户名。

例如(作为root)可以这样做:

# su postgres -c 'psql dgrt' 

这同样适用于远程主机的连接。有关详细信息,请参阅文档。

参考: