我试图在Ubuntu 14上使用Postgres为一个rails应用程序运行Capistrano,我在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
我尝试过类似帖子的每个解决方案,但没有运气。对于踢,我也尝试在远程应用程序目录中运行该命令并得到以下内容:
PG::ConnectionBad: FATAL: password authentication failed for user "mll"
FATAL: password authentication failed for user "mll"
这很有趣,因为它使用我的数据库名称作为我的用户名。请参阅下面的database.yml
,所以最后我添加了一个mll
角色,并且看看它在运行rake db:migrate
时是否有效。我尝试使用这个新角色再次运行Capistrano,但仍然没有运气。
是否合理猜测用户名未被正确访问/存储?我有什么方法可以测试吗?我为ALTER ROLE ben WITH PASSWORD 'mypw';
和ben
角色手动mll
,没有。
我的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 | {}
我看到将md5
更改为trust
帮助了一些人,我试过了,但我不确定如何重新启动,我所看到的所有命令都无法工作对我来说。
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
答案 0 :(得分:3)
你应该使用&#34; trust&#34;在pg_hba.conf
中的localhost方法下。请注意,这意味着来自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
更改pg_hba.conf
后,您可以使用pg_ctl reload
答案 1 :(得分:0)
解决此问题的最佳做法是-
在开发组和捆绑安装的 Gemfile 中添加以下gem。
gem'capistrano-postgresql'
在 Capfile
中添加以下行需要“ capistrano / postgresql”
在 config / deploy.rb 或 config / deploy / *。rb
中添加以下行设置:pg_password,ENV ['DATABASE_PASSWORD']
设置:pg_ask_for_password,正确