分享是學習的原動力
RSS icon Email icon Home icon
  • Unable to connect to PostgreSQL server: FATAL: no pg_hba.conf entry for host "58.86.221.52", user "test", database "test_db", SSL off in

    Posted on 十二月 8th, 2008 oscar 1 comment   

    今天在進行資料庫轉移到出現以下錯誤訊息:

    Unable to connect to PostgreSQL server: FATAL: no pg_hba.conf entry for host "58.86.221.52", user "test", database "test_db", SSL off in

    到google問了一下才知道,原來是認證問題,以下引用了PostgreSQL 7.4devel 文檔

    19.3. 認證問題

    真正的認證失敗以及相關的問題通常由類似下面的錯誤信息 表白自身.

    FATAL:  no pg_hba.conf entry for host "123.123.123.123", user "andym", database "testdb"

    這條信息出現的最大可能是你已經聯接了服務器,但她不願意和你說話. 就象信息自己表示的那樣,服務器拒絕了聯接請求,因為她沒有在她的 pg_hba.conf 配置文件裡找到認證記錄.

    Password authentication failed for user 'andym'

    這樣的信息表示你聯接了服務器,並且她也願意和你交談,但是 你必須通過pg_hba.conf 文件裡聲明的 認證方法.檢查你提交的口令,或者如果錯誤信息提到 這些 Kerberos 或 IDENT 認證類型時 檢查你的這些軟件.

    FATAL 1:  user "andym" does not exist

    這是表示此用戶不存在的另一方法.

    FATAL 1:  Database "testdb" does not exist

    你試圖聯接的數據庫不存在.請注意如果你沒有聲明數據庫名,缺省 是數據庫用戶名,這可能正確也可能不正確.

    請注意服務器日志可能包含比報告給客戶端的更多的 有關認證失敗的信息.如果你被失敗的原因搞糊塗了,那麼請檢查日志.

     

    解決方法如下:

    1.加入認證記錄

    [root@custom ~]# vi /var/lib/pgsql/data/pg_hba.conf

    # TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD

    # "local" is for Unix domain socket connections only

    local   all         all                               password

    # IPv4 local connections:

    #host    all         all         127.0.0.1/32               password

    host     all         all         192.168.1.1/24            password

    host     all        all         58.86.221.52/24          password

    #加入此行即可

    2.重開postgresql

    [root@custom ~]# service postgresql restart

    Powered by

    • Share/Bookmark
     

    One response to “Unable to connect to PostgreSQL server: FATAL: no pg_hba.conf entry for host "58.86.221.52", user "test", database "test_db", SSL off in”

    1. [...] Unable to connect to PostgreSQL server: FATAL: no pg_hba.conf entry for host "58.86.221.52&quot… [...]

    Leave a reply