psql: FATAL: Ident authentication failed for user "username" 錯誤處理方式

2011/08/24 張貼者: Damon.Huang
剛安裝好的Postgresl, 未經過設定時,使用新建立的User,登入時發生的狀況
psql -d blahDB -U Qoo -W
Password for user Qoo:  <輸完密碼後 ...>

psql: FATAL: Ident authentication failed for user Qoo

預設的認證方式只需採用 IDENT-based 認證(使用者認證) 修正方式:
此處是以 Ubuntu 的位置為範例
# vi /etc/postgresql/8.4/main/pg_hba.conf 
原始格式
# Database administrative login by UNIX sockets
local   all         postgres                          ident

# TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD

# "local" is for Unix domain socket connections only
local   all         all                               ident

# IPv4 local connections:
host    all         all         127.0.0.1/32          md5

# IPv6 local connections:
host    all         all         ::1/128               md5
加入以下的資訊
# Database administrative login by UNIX sockets
local   all         postgres                          ident

# TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD
local   all         all                               trust

# IPv4 local connections:
host    all         all         127.0.0.1/32          md5
host    all         all         127.0.0.1/32          trust
host    all         all         172.18.0.0/24         trust
host    all         all         172.18.3.0/24         trust
重啟服務並重新登入測試
# service postgresql restart
# psql -d blahDB -U Qoo -W 

Reference:

標籤:

張貼留言

技術提供:Blogger.