2017-03-10 52 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' 

這同樣適用於遠程主機的連接。有關詳細信息,請參閱文檔。

參考: