我在CentOS上設置了一個Postgres數據庫服務器,並創建了一個數據庫mydb
。ident 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
是本地IPv6
和IPv4
連接的默認方法。
我把這個從ident
更改爲md5
。
然後,通過Pgadmi3連接和psql
按預期方式工作
爲什麼ident
失敗?
http://www.postgresql.org/docs/9.4/static/auth-methods.html – zerkms