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"
只給你在安裝'Postgres'時輸入的密碼 – 2014-10-09 04:28:00
試過了。沒有運氣。 – Aaron 2014-10-09 04:57:04
我想說你改變'pg_hba.conf'後忘記重新啓動/重新加載PostgreSQL – 2014-10-09 06:02:30