3 回答

TA貢獻(xiàn)1934條經(jīng)驗(yàn) 獲得超2個(gè)贊
從命令行連接到postgres時(shí),不要忘記添加-h localhost為命令行參數(shù)。如果沒有,postgres將嘗試使用PEER身份驗(yàn)證模式進(jìn)行連接。
下面顯示了密碼的重置,通過PEER身份驗(yàn)證失敗的登錄以及使用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
失?。?/p>
# 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貢獻(xiàn)1804條經(jīng)驗(yàn) 獲得超7個(gè)贊
自給出這些答案以來,pg_hba.conf(C:\Program Files\PostgreSQL\9.3\data)文件已更改。什么工作對(duì)我來說,在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
添加回答
舉報(bào)