2014-10-09 25 views
1

我在我的Mac上安裝了PostgreSQL 9.3。我試圖做到這一點的命令:即使pg_hba.conf表示信任,Postgres也會詢問密碼


$ sudo -u postgres psql template1 
Password: 
Password: 
psql: FATAL: password authentication failed for user "postgres" 

正如你所看到的,它要求輸入密碼,這是我給它。它失敗了。我嘗試postgres用戶的密碼和計算機密碼。它總是說它失敗了。

我讀到你可以改變pg_hba.conf文件來不要求輸入密碼。它是如下:

> # TYPE DATABASE  USER   ADDRESS     METHOD 
> 
> # "local" is for Unix domain socket connections only 
> local all    all          trust 
> # IPv4 local connections: 
> host all    all    127.0.0.1/32   trust 
> # IPv6 local connections: 
> host all    all    ::1/128     trust 
> # Allow replication connections from localhost, by a user with the 
> # replication privilege. 
> local replication  postgres        trust 
> host replication  postgres  127.0.0.1/32   trust   
> host replication  postgres  ::1/128     trust 

從我的理解,這不應該要求輸入密碼。但它確實如此。

有意思的是:它在pgAdmin3中正常記錄。但不是在終端。

更新#1:

嘗試重新啓動PostgreSQL的更改pg_hba.conf文件之後。這是我得到的消息。

$ pg_ctl -D postgres -l server.log restart 
pg_ctl: PID file "postgres/postmaster.pid" does not exist 
Is server running? 
starting server anyway 
pg_ctl: could not read file "postgres/postmaster.opts" 
+0

只給你在安裝'Postgres'時輸入的密碼 – 2014-10-09 04:28:00

+0

試過了。沒有運氣。 – Aaron 2014-10-09 04:57:04

+0

我想說你改變'pg_hba.conf'後忘記重新啓動/重新加載PostgreSQL – 2014-10-09 06:02:30

回答

0

原來我的系統上安裝了兩個PostgreSQL版本。 8.4和9.3。每當安裝8.4時,所有的默認設置都被設置爲使用它而不是9.3。所以即使9.3不會要求權限,或者密碼,8.4也是如此。

終於能夠殺死正在運行的8.4版本。並將流量重定向到9.3。它現在有效!

我將8.4的pg_hba.conf文件設置爲信任以防萬一。

相關問題