2012-07-31 85 views
3

我在Windows Server 2003上安裝了PostgreSQL版本8.3.19。配置完成後,我可以從本地(從php腳本)訪問,但不能遠程訪問(從另一臺類似的PHP腳本,從另一臺機器)。
1)NAT配置和測試端口5432
2)防火牆授權應用
3)I設置pg_hba.conf文件:在windows上遠程訪問postgresql

host all all 0.0.0.0/0 md5 

4)我設置在postgresql.conf:

listen_addresses='*' 

5)我用pgAdminIII爲應用程序的訪問創建了一個角色。我宣佈他的超級用戶(只是爲了測試),並給他取名TOTO
6)我的本地腳本是:

$con=pg_connect("host=localhost port=5432 user=TOTO password=PW dbname=test") 

7)我的遠程腳本是:

$con=pg_connect("host=myhostname port=5432 user=TOTO password=PW dbname=test") 

我看不出有什麼我可以忘記。你能點亮我嗎?

+3

你得到了什麼錯誤? – 2012-07-31 16:30:42

+0

我不知道;-(我試過pg_last_error但是返回空白,由於回覆很長,我想有一個超時時間, – Bertaud 2012-07-31 16:34:40

+0

是否嘗試通過命令行遠程連接到postgres? – mask8 2012-07-31 16:36:24

回答

2

如果你正在獲取超時,那麼mask8說它可能是防火牆配置問題。看看你是否可以從服務器本身連接到目標IP。在postgresql的配置中啓用連接日誌記錄。

哦,除非你確實需要使用該版本,否則安裝9.1,8.3很快就會退役。

+0

我想通過psql -U TOTO -h localhost -p 5432 -W -d test?如果是的話我可以 – Bertaud 2012-07-31 21:50:04

+0

從EnterpriseDB下載? postgresql.org上不存在pgInstaller 9.1.x! – Bertaud 2012-07-31 21:59:21

+0

當然,EnterpriseDB做的是windows打包。不要在測試中使用「-h localhost」,請使用「-h 123.123.123.123」或任何外部IP地址。 – 2012-08-01 10:37:26