2015-01-16 34 views
2

我在CentOS上設置了一個Postgres數據庫服務器,並創建了一個數據庫mydbident vs md5 for Postgres身份驗證

我訪問psql作爲系統用戶postgres和檢查,看看它是否存在:

$ sudo -u postgres -i 
$ psql 
postgres=# \l 

Name | Owner | ...  
-------------------- 
mydb | postgres | ... 

我然後將其配置:

(1)listen_addresses = 'localhost'postgresql.conf註釋。

(2)我爲用戶postgres設置了密碼。

sudo -u postgres psql template1 
ALTER USER postgres with encrypted password 'my_password'; 

但是,通過psql -U postgres -h localhost連接和Pgadm3失敗,此錯誤:

Ident autentication failed for user "postgres" 

我檢查/var/lib/pgsql/9.4/data/pg_hba.conf

ident是本地IPv6IPv4連接的默認方法。

我把這個從ident更改爲md5

然後,通過Pgadmi3連接和psql按預期方式工作

爲什麼ident失敗?

+0

http://www.postgresql.org/docs/9.4/static/auth-methods.html – zerkms

回答

4

它失敗,因爲:

The ident authentication method works by obtaining the client's operating system user name from an ident server and using it as the allowed database user name (with an optional user name mapping). This is only supported on TCP/IP connections.

ident應該意味着UNIX標識。爲了ident工作,您必須運行psqlPGAdminpostgres用戶(默認Postgres在CentOS上處理所有者)。所以請確保你製作了sudo su - postgressudo - postgres(它的工作原理與你所示的一樣)。

md5實際上是指md5哈希密碼標識。對我個人而言,這是最簡單的方法。

我敢肯定,在你的榜樣一切正常:-)