1. 程式人生 > >關於連線PostgreSQL時提示 FATAL: password authentication failed for user "連線使用者名稱" 的解決辦法【自己試驗通過】

關於連線PostgreSQL時提示 FATAL: password authentication failed for user "連線使用者名稱" 的解決辦法【自己試驗通過】

借鑑

https://my.oschina.net/u/3371661/blog/3040763

一直以為是密碼設錯了,其它應該是許可權問題【個人理解】

alter role postgres with password '123';

 

解決方法
1、編輯pg_hba.conf,將md5認證修改成trust認證,編輯後退出儲存

3、psql連線,用alter role修改密碼
[postgres @ pgsqldb-master bin]$ psql
psql (9.2.3)
Type "help" for help.

postgres=# alter role postgres with password '123';
ALTER ROLE
postgres=#

4、退出psql
5、編輯pg_hba.conf,將turst認證修改成md5認證,編輯後退出儲存

重啟

systemctl restart postgresql-9.6

在postgres使用者下執行下面,輸入密碼可以進去,就說明密碼設定成功了。

psql -h 127.0.0.1 -U postgres

 

這時如果pg_hba.conf如果有遠端配置

host    all             all             0.0.0.0/0            md5

postgres.conf中

listen_addresses = '*'