用pgadmin3 新建服務器出現錯誤 Peer authentication failed for user "postgres"
在stackoverflow上找到答案,出現此錯誤的原因是:
Peer authentication 是默認的配置,如果你的計算機用戶名和你的postgres數據庫名是一樣的話,那么就不會出現此錯誤,不需要為你的數據庫設置密碼。
還有一種md5 authentication,它需要密碼。
而我的計算機用戶名和我的數據庫名不一致,所以需要把Peer authentication改成md5 authentication,然后給數據庫設置密碼。
在哪里改?
/etc/postgresql/9.3/main/pg_hba.conf
執行命令
找到下面的一行:
local all postgres peer
改成
local all postgres md5
然后restart postgresql server
sudo service postgresql restart
