[英]capistrano, rails, PG::ConnectionBad: fe_sendauth: no password supplied
I'm trying to run Capistrano for a rails app with Postgres on Ubuntu 14, I ran into a password error during rake db:migrate
- 我正试图在Ubuntu 14上运行Capistrano与Postgres的rails应用程序,我在
rake db:migrate
期间遇到密码错误 -
DEBUG [2823f146] Command: cd /home/ben/apps/mll/releases/20160414014303 && ( export RBENV_ROOT="$HOME/.rbenv" RBENV_VERSION="2.0.0-p645" RAILS_ENV="production" ; $HOME/.rbenv/bin/rbenv exec bundle exec rake db:migrate )
DEBUG [2823f146] rake aborted!
PG::ConnectionBad: fe_sendauth: no password supplied
I tried every solution to similar posts but no luck. 我试过类似帖子的每个解决方案,但没有运气。 For kicks I also tried running just that command in the remote app dir and got the following:
对于踢,我也尝试在远程应用程序目录中运行该命令并获得以下内容:
PG::ConnectionBad: FATAL: password authentication failed for user "mll"
FATAL: password authentication failed for user "mll"
This is interesting because it's using my database name as my username. 这很有趣,因为它使用我的数据库名称作为我的用户名。 See
database.yml
below, so for the hell of it I added a mll
role, and lo and behold it worked when just running rake db:migrate
. 请参阅下面的
database.yml
,所以对于它的地狱,我添加了一个mll
角色,并且看到它在运行rake db:migrate
。 I tried running Capistrano again though with this new role, and still no luck. 虽然有了这个新角色,我尝试再次运行卡皮斯特拉诺,但仍然没有运气。
Is it a reasonable guess that the username is not being accessed/stored properly? 是否合理猜测用户名未被正确访问/存储? Any way for me to test that?
我有什么方法可以测试吗? I manually
ALTER ROLE ben WITH PASSWORD 'mypw';
我手动改变
ALTER ROLE ben WITH PASSWORD 'mypw';
for both my ben
and mll
roles, and nothing. 对于我的
ben
和mll
角色,什么都没有。
My database.yml: 我的database.yml:
defaults: &default
adapter: sqlite3
encoding: utf8
development:
<<: *default
database: db/development.sqlite3
test:
<<: *default
database: db/development.sqlite3_test
production:
<<: *default
host: localhost
adapter: postgresql
encoding: utf8
database: mll
pool: 5
username: <%= ENV['DATABASE_USER'] %>
password: <%= ENV['DATABASE_PASSWORD'] %>
\\du: \\杜:
List of roles
Role name | Attributes | Member of
-----------+------------------------------------------------+-----------
ben | Superuser, Create role, Create DB | {}
mll | Superuser, Create role, Create DB | {}
postgres | Superuser, Create role, Create DB, Replication | {}
I read changing md5
to trust
helped some people, I tried that, but I'm unsure how to restart, all commands I've seen haven't worked for me. 我读过更改
md5
以trust
帮助了一些人,我试过了,但我不确定如何重新启动,我看到的所有命令都没有为我工作。
pg_hba.conf: pg_hba.conf的:
local all postgres peer
# TYPE DATABASE USER ADDRESS METHOD
local all all peer
host all all 127.0.0.1/32 md5
host all all ::1/128 md5
You should use "trust" under method for localhost in pg_hba.conf
. 您应该在
pg_hba.conf
使用localhost方法下的“trust”。 Note that this means all connections from localhost will be able to login as any user, which is probably fine as long as you're using this for development. 请注意,这意味着来自localhost的所有连接都可以作为任何用户登录,只要您将其用于开发,这可能就好了。
# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 trust
After changing your pg_hba.conf
you can restart postgres with pg_ctl reload
更改
pg_hba.conf
您可以使用pg_ctl reload
重新启动postgres
The best practice to resolve the issue is - 解决问题的最佳做法是 -
Add the below gem in your Gemfile under development group and bundle install. 在开发组和bundle install下的Gemfile中添加以下gem。
gem 'capistrano-postgresql' 宝石'capistrano-postgresql'
Add the below line in Capfile 在Capfile中添加以下行
require 'capistrano/postgresql' 要求'capistrano / postgresql'
Add below lines in config/deploy.rb or in config/deploy/*.rb 在config / deploy.rb或config / deploy / * .rb中添加以下行
set :pg_password, ENV['DATABASE_PASSWORD'] set:pg_password,ENV ['DATABASE_PASSWORD']
set :pg_ask_for_password, true set:pg_ask_for_password,true
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.