iT邦幫忙

0

PostgresSQL 設定 pgAdmin III 連線問題

maxcp 2012-09-06 18:08:1913891 瀏覽

請問我PostgresSQL 8.4 架在VM ubuntu 11.04 ,IP 為192.168.81.134,沒開防火牆,
在遠端打開 phppgadmin 管理沒有問題,但想用pgAdmin III連線一直都連不上,不知道有沒有高手可以幫我解決,
/etc/postgresql/8.4/main/pg_hba.conf 設定檔內容如下:
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
host all all 192.168.11.1/24 md5
host all all 192.168.11.1/24 trust
host all all 192.168.84.1/24 trust

IPv6 local connections:

host all all ::1/128 md5

/etc/postgresql/8.4/main/postgresql.conf 有加上

listen_addresses = '*'
port = 5432

圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

2 個回答

4
bizpro
iT邦大師 1 級 ‧ 2012-09-06 20:53:47
最佳解答

no pg_hba.conf entry for host "192.168.81.1"

跑pgadmin III的機器的IP是192.168.81.1, 並未被授權連線postgresql server, 必須在pg_hba.conf中授權, 加入:
host all all 192.168.81.1/32 trust

/etc/postgresql/8.4/main/pg_hba.conf 設定檔內容如下:
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
host all all 192.168.11.1/24 md5
host all all 192.168.11.1/24 trust
host all all 192.168.84.1/24 trust
host all all 192.168.81.1/32 trust

IPv6 local connections:

host all all ::1/128 md5

至於192.168.11.1/24, 192.168.11.1/24, 192.168.84.1/24應該都改為
192.168.11.1/32, 192.168.11.1/32, 192.168.84.1/32

至於官方建議的:
[quote]You'll probably want to add something like
host all all 192.168.0.0/24 md5[quote]
則不必這樣做, 每次只需開放單一IP就好了.

maxcp iT邦新手 4 級 ‧ 2012-09-07 08:41:41 檢舉

哈~謝啦!原來是IP打錯了!可以連線了~謝謝

4
一級屠豬士
iT邦大師 1 級 ‧ 2012-09-06 20:53:42

你的設定 host all all 192.168.84.1/24 trust
錯誤訊息的提示 something like host all all 192.168.0.0/24 md5

建議改成 host all all 192.168.84.0/24 trust
當然還有其他網段也改,試試看.

maxcp iT邦新手 4 級 ‧ 2012-09-07 08:44:16 檢舉

哈~謝啦!原來是IP打錯了!host all all 192.168.81.1/32 trust 可以連線了~謝謝

我要發表回答

立即登入回答