postgresql PG::ConnectionBad:致命:用户“alphauser”的密码验证失败
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28793606/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
PG::ConnectionBad: FATAL: password authentication failed for user "alphauser"
提问by Madalina
I'm working on an application in Rails for my college. The application was started by the students from previous year and now it's me and my colleagues turn to continue work on it. I took the application from github, I run bundle install, but when to run rake db:migrate
I got this PG::ConnectionBad: FATAL: password authentication failed for user "alphauser"
.
In database.yml I have these
我正在为我的大学编写 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
I don't know what to do in this case.
在这种情况下,我不知道该怎么办。
回答by Mikhail Chuprynski
You have to create corresponding user and database manually like this:
您必须像这样手动创建相应的用户和数据库:
in shell:
psql
在外壳中:
psql
then:
然后:
create user alphauser with password 'alphapassword';
create database alpha_database owner alphauser;
alter user alphauser superuser createrole createdb replication;
\q
don't forget semicolons.
不要忘记分号。
回答by Salma Gomaa
Try to use:
尝试使用:
sudo -u postgres createuser --interactive --pwprompt
sudo -u postgres createuser --interactive --pwprompt
to add the role and the password
添加角色和密码
回答by george
So the problem is with your rails application using the database.yml
file to try and connect to your local database and failing to find the user alphauser
(since I assume you're using different computers/environments as the previous students).
所以问题在于您的 rails 应用程序使用该database.yml
文件尝试连接到您的本地数据库,但未能找到用户alphauser
(因为我假设您使用的是与以前的学生不同的计算机/环境)。
Databases have users similar to applications, the postgres documentation is pretty dense on this, but I would guess if you can create a user alphauser
, and make it's password alphapassword
then you will have a new clean database for your app that you can run rake db:migrate
on.
数据库有类似于应用程序的用户,postgres 文档在这方面非常密集,但我想如果您可以创建一个 user alphauser
,并设置它的密码,alphapassword
那么您将拥有一个新的干净的应用程序数据库,您可以在其rake db:migrate
上运行。
Postgres docs: http://www.postgresql.org/docs/9.2/static/app-createuser.html
Postgres 文档:http: //www.postgresql.org/docs/9.2/static/app-createuser.html
Try running this command from the command line createuser -P -s -e alphauser
尝试从命令行运行此命令 createuser -P -s -e alphauser
This will prompt for a password, which is alphauserpassword
这将提示输入密码,即 alphauserpassword
回答by vidur punj
create user alphauser with password 'alphapassword';
Then
然后
rake db:setup