Ruby on rails postgresql数据库迁移错误:PG::ConnectionBad:fe_sendauth:未提供密码
我试图在rails应用程序中运行Ruby on rails postgresql数据库迁移错误:PG::ConnectionBad:fe_sendauth:未提供密码,ruby-on-rails,postgresql,database-migration,Ruby On Rails,Postgresql,Database Migration,我试图在rails应用程序中运行rake db:migrate,但出现以下错误: PG::ConnectionBad: fe_sendauth: no password supplied 我的数据库.yml如下所示: <% branch = `git symbolic-ref HEAD 2>/dev/null`.chomp.sub('refs/heads/', '') branch = 'master' if branch.empty? suffix = branch
rake db:migrate
,但出现以下错误:
PG::ConnectionBad: fe_sendauth: no password supplied
我的数据库.yml
如下所示:
<%
branch = `git symbolic-ref HEAD 2>/dev/null`.chomp.sub('refs/heads/', '')
branch = 'master' if branch.empty?
suffix = branch == 'master' || branch.starts_with?('hotfix') ? '' : "_" + `git config --local --get offgrid.databases.#{branch.gsub(/[^a-zA-Z0-9]/,'')}`.strip
suffix = ENV['DB_SUFFIX'] if ENV['DB_SUFFIX']
puts "Database is 'offgrid_dev#{suffix}'" if Rails.env.development?
%>
development:
adapter: postgresql
database: offgrid_dev<%= suffix %>
host: localhost
encoding: unicode
pool: 5
password: 1
test:
adapter: postgresql
database: offgrid_test<%= suffix %><%= ENV['TEST_ENV_NUMBER'] %>
host: localhost
encoding: unicode
pool: 5
password: 1
我的测试数据库成功迁移,没有给出密码错误
这是非常令人困惑的,因为我对测试和开发环境都有或多或少相同的配置
我的第一个问题是为什么会这样
但更重要的是,我如何克服这一点
我尝试将密码更改为无,方法是使用psql
控制台将密码设置为:\password
,在没有输入新密码的情况下单击return并确认,然后运行迁移,但没有成功。我还尝试运行迁移,同时将环境指定为:rakedb:migraterails\u ENV=development
,但也没有成功
我到底在干什么?我怎么才能把它弄起来
非常感谢你的帮助
PS:我的操作系统是ubuntu。。。在
stackoverflow
上搜索更多信息后,我得到了,它指向
接下来,如中所述,使用默认的用户名
和密码
配置我的.pgpass
文件,一切正常
尽管如此,我仍然不明白为什么它以前用于我的测试环境数据库,而不是开发环境数据库
rake db:migrate RAILS_ENV=test