Ruby on rails capistrano,rails,PG::ConnectionBad:fe_sendauth:未提供密码

Ruby on rails capistrano,rails,PG::ConnectionBad:fe_sendauth:未提供密码,ruby-on-rails,postgresql,capistrano,Ruby On Rails,Postgresql,Capistrano,我试图在Ubuntu14上为带有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/bi

我试图在Ubuntu14上为带有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
我尝试了所有类似帖子的解决方案,但没有成功。对于kicks,我还尝试在远程应用程序目录中运行该命令,并得到以下结果:

PG::ConnectionBad: FATAL:  password authentication failed for user "mll"
FATAL:  password authentication failed for user "mll"
这很有趣,因为它使用我的数据库名作为用户名。请参见下面的
database.yml
,因此我添加了一个
mll
角色,当运行
rake db:migrate
时,它就工作了。我试着再次担任卡皮斯特拉诺这个新角色,但仍然没有成功

是否有理由猜测用户名未被正确访问/存储?有什么办法让我测试一下吗?我手动
使用密码“mypw”更改角色ben用于我的
ben
mll
角色,没有任何内容

My 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'] %>
我读到将
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
您应该在
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

重新启动postgres,解决此问题的最佳做法是-

  • 在开发组和捆绑安装下的gem文件中添加以下gem

    gem'capistrano postgresql'

  • Capfile中添加以下行

    需要“capistrano/postgresql”

  • config/deploy.rbconfig/deploy/*.rb

    设置:pg\u密码,ENV['DATABASE\u password']

    设置:pg\u询问密码,true


  • 我觉得自己像个傻瓜,终于用SQL
    SELECT pg_reload_conf()重新启动了它和狗屎,这起作用了。谢谢。没问题,我们都去过。关于生产,我能读到的任何资源/主题,关于我如何确保安全,而不是遇到这个问题?不管密码如何,这个解决方案都能工作。这将信任所有连接。因此,我们需要使用md5作为最佳实践。
    
    # "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