![](/img/trans.png)
[英]PG::ConnectionBad: FATAL: password authentication failed for user
[英]PG::ConnectionBad: FATAL: password authentication failed for user “alphauser”
我正在為我的大學開發一個Rails應用程序。 該應用程序是由去年的學生開始的,現在是我和我的同事轉而繼續工作。 我從github上獲取了應用程序,我運行了bundle install,但是什么時候運行rake db:migrate
我得到了這個PG::ConnectionBad: FATAL: password authentication failed for user "alphauser"
。 在database.yml我有這些
development:
adapter: postgresql
encoding: unicode
database: alpha_database
host: localhost
pool: 5
username: alphauser
password: alphapassword
我不知道在這種情況下該怎么做。
您必須手動創建相應的用戶和數據庫,如下所示:
在shell中: psql
然后:
create user alphauser with password 'alphapassword';
create database alpha_database owner alphauser;
alter user alphauser superuser createrole createdb replication;
\q
不要忘記分號。
嘗試使用:
sudo -u postgres createuser --interactive --pwprompt
添加角色和密碼
所以問題在於使用database.yml
文件的rails應用程序嘗試連接到本地數據庫並且無法找到用戶alphauser
(因為我假設您使用的是與之前學生不同的計算機/環境)。
數據庫的用戶與應用程序類似,postgres文檔非常密集,但我想如果你可以創建一個用戶alphauser
,並使其密碼為alphapassword
那么你將為你的應用程序創建一個新的干凈數據庫,你可以運行rake db:migrate
。
Postgres docs: http : //www.postgresql.org/docs/9.2/static/app-createuser.html
嘗試從命令行createuser -P -s -e alphauser
運行此命令
這將提示輸入密碼,即alphauserpassword
create user alphauser with password 'alphapassword';
然后
rake db:setup
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.