![](/img/trans.png)
[英]PG::ConnectionBad: FATAL: password authentication failed for user
[英]PostgreSQL: FATAL - password authentication failed for user (PG::ConnectionBad)
這是我的database.yml :
development:
adapter: postgresql
database: myUsername
username: myUsername
password: myPassword
host: localhost
因此,當我轉到本地頁面時,不會顯示任何錯誤。 如果我將database.yml 中的密碼更改為不正確的內容,我會得到
PG::ConnectionBad: FATAL: password authentication failed for user "myUsername" FATAL: password authentication failed for user "myUsername"
錯誤。 因此,我的密碼是正確的。
但是,當我跑步時
rake db:migrate
無論我的密碼是對還是錯,我都會收到錯誤消息。 如果正確,我會收到以下錯誤:
PG::ConnectionBad: fe_sendauth: no password supplied
如果錯誤,我會收到與本地頁面相同的錯誤:
PG::ConnectionBad: FATAL: password authentication failed for user "myUsername" FATAL: password authentication failed for user "myUsername"
是什么導致它認為“未提供”正確的密碼? 請,任何幫助或信息表示贊賞,我已經弄亂了兩天了。
如果您的密碼與用戶名匹配,這應該可以工作。
允許連接到 PostgreSQL 有兩個步驟:
1.為postgres用戶設置密碼
在 Linux 系統上,沒有設置默認密碼。
要設置默認密碼:
從 postgres 用戶帳戶運行 psql 命令:
sudo -u postgres psql postgres
設置密碼:
\password postgres
輸入密碼。
關閉 psql。
\q
在此之后,我們將在步驟 2 中更改 postgres 用戶的密碼
N/B:第 2 步非常重要,否則您仍然會遇到相同的Authenticate Failure問題。
2.修改postgres用戶的密碼
如果您不知道用戶的密碼
從 postgres 用戶帳戶運行 psql 命令:
sudo passwd postgres
輸入密碼。
要測試並確認密碼更改或設置,請從 postgres 用戶帳戶運行 psql 命令:
su - postgres
輸入您剛剛設置的新密碼。
要退出 postgreql 環境,只需鍵入以下命令
exit
就這樣。
如果執行這些步驟后,您遇到如下問題
Postgresql:致命:角色不存在
只需按照此鏈接中的答案(答案:Postgresql:致命:角色不存在)來解決問題。
我希望這有幫助
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.