3 回答

TA貢獻1934條經驗 獲得超2個贊
從命令行連接到postgres時,不要忘記添加-h localhost為命令行參數。如果沒有,postgres將嘗試使用PEER身份驗證模式進行連接。
下面顯示了密碼的重置,通過PEER身份驗證失敗的登錄以及使用TCP連接的成功登錄。
# sudo -u postgres psql
could not change directory to "/root"
psql (9.1.11)
Type "help" for help.
postgres=# \password
Enter new password:
Enter it again:
postgres=# \q
失敗:
# psql -U postgres -W
Password for user postgres:
psql: FATAL: Peer authentication failed for user "postgres"
使用-h localhost:
# psql -U postgres -W -h localhost
Password for user postgres:
psql (9.1.11)
SSL connection (cipher: DHE-RSA-AES256-SHA, bits: 256)
Type "help" for help.
postgres=#

TA貢獻1804條經驗 獲得超7個贊
自給出這些答案以來,pg_hba.conf(C:\Program Files\PostgreSQL\9.3\data)文件已更改。什么工作對我來說,在Windows中,是打開文件并更改METHOD從md5到trust:
# TYPE DATABASE USER ADDRESS METHOD
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 trust
然后,使用pgAdmin III,我不使用密碼登錄,并通過以下方式更改了用戶postgres'密碼:File -> Change Password
添加回答
舉報