關於鏈接PostgreSQL時提示 FATAL: password authentication failed for user "鏈接用戶名" 的解決辦法【本身試驗經過】

借鑑sql

http://www.javashuo.com/article/p-zhwuxoug-da.htmlpost

一直覺得是密碼設錯了,其它應該是權限問題【我的理解】.net

alter role postgres with password '123';rest

 

解決方法
一、編輯pg_hba.conf,將md5認證修改爲trust認證,編輯後退出保存postgresql

三、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=#blog

四、退出psql
五、編輯pg_hba.conf,將turst認證修改爲md5認證,編輯後退出保存md5

重啓get

systemctl restart postgresql-9.6it

在postgres用戶下執行下面,輸入密碼能夠進去,就說明密碼設置成功了。ast

root下面也能夠直接輸入下面句子

psql -h 127.0.0.1 -U postgres

 

這時若是pg_hba.conf若是有遠程配置

host    all             all             0.0.0.0/0            md5

postgres.conf中

listen_addresses = '*'

遠程則也能夠了

相關文章
相關標籤/搜索