2013-03-26 118 views
3

postgreSQL.conf看起來像Postgres的:本地主機連接不

# - Connection Settings - 

listen_addresses = '*'   # what IP address(es) to listen on; 
             # comma-separated list of addresses; 
             # defaults to 'localhost', '*' = all 
             # (change requires restart) 
port = 5432        # (change requires restart) 

而且我也知道,Postgres的運行

air:data postgres$ ps -aef | grep postgres 
    504 16474 16473 0 11:34AM ??   0:00.00 postgres: logger process 
    504 16476 16473 0 11:34AM ??   0:00.00 postgres: writer process 
    504 16477 16473 0 11:34AM ??   0:00.00 postgres: wal writer process 
    504 16478 16473 0 11:34AM ??   0:00.00 postgres: autovacuum launcher process 
    504 16479 16473 0 11:34AM ??   0:00.00 postgres: stats collector process 
    0 16087 16078 0 10:54AM ttys001 0:00.03 su - postgres 
    504 16473  1 0 11:34AM ttys001 0:00.22 /Library/PostgreSQL/9.1/bin/postgres -D/Library/PostgreSQL/9.1/data 
    504 16484 16088 0 11:34AM ttys001 0:00.00 grep postgres 

但我無法連接

psql -Uuser -W 
Password for user user: 
psql: could not connect to server: No such file or directory 
    Is the server running locally and accepting 
    connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"? 

而且,當我運行以下

lsof -i tcp:5432 
✘ [email protected]:37:13 ⮀ ~ ⮀ netstat -a | grep postgres 
tcp6  0  0 *.postgres    *.*     LISTEN 
tcp4  0  0 *.postgresql   *.*     LISTEN 

它說什麼都沒有運行port 5432 我錯過了什麼?

UPDATE

pg_hba.conf看起來像

# TYPE DATABASE  USER   ADDRESS     METHOD 

# "local" is for Unix domain socket connections only 
local all    all          md5 
# IPv4 local connections: 
host all    all    127.0.0.1/32   md5 
# IPv6 local connections: 
host all    all    ::1/128     md5 
+0

你是否在Mac OS X機器上? (通常很好提及你的平臺) – 2013-03-26 23:38:24

+0

我的不好,是的,我正在使用Mac OS X – daydreamer 2013-03-27 03:37:45

回答

1

您需要使用自帶的是你,而不是安裝在psql/usr/bin目錄PostgreSQL的包是部分psql程序蘋果系統。

例如,如果使用postgres.app,他們在documentation說:

的Mac OS 10.7附帶了一箇舊版本的PostgreSQL,它可以是 開始用下面的命令:

$ PSQL -h本地主機PostgreSQL附帶一系列有用的 二進制文件,如pg_dump或pg_restore,您可能希望使用 。來吧,加入/ bin目錄中附帶Postgres.app 到PATH(最好的.profile,.bashrc中,.zshrc,等來 確保此獲取每一個終端會話設置):

PATH =「/ Applications/Postgres.app /目錄/ MacOS/bin:$ PATH」
一旦你的 路徑設置正確,你應該可以在沒有 主機的情況下運行psql。 (如果沒有,檢查正確的版本被在 PATH做這PSQL加載)

如果使用預包裝的PostgreSQL的另一個來源,它與不同的路徑同樣的事情。

3

pg_hba.conf中:

host all    all    127.0.0.1/32   trust 

最後一欄更改爲trust

0

你可以嘗試停止服務和agian星服務。一旦你重新加載配置文件。在工作或不工作時再次檢查。