在Prodcution中,当我尝试访问rails c
并在数据库上运行任何命令时,我收到以下错误
2.3.1 :001 > Campaign.all
PG::ConnectionBad: fe_sendauth: no password supplied
from /usr/local/rvm/gems/ruby-2.3.1/gems/activerecord-4.2.5.2/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `initialize'
from /usr/local/rvm/gems/ruby-2.3.1/gems/activerecord-4.2.5.2/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `new'
from /usr/local/rvm/gems/ruby-2.3.1/gems/activerecord-4.2.5.2/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `connect'
from /usr/local/rvm/gems/ruby-2.3.1/gems/activerecord-4.2.5.2/lib/active_record/connection_adapters/postgresql_adapter.rb:242:in `initialize'
from /usr/local/rvm/gems/ruby-2.3.1/gems/activerecord-4.2.5.2/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `new'
from /usr/local/rvm/gems/ruby-2.3.1/gems/activerecord-4.2.5.2/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `postgresql_connection'
from /usr/local/rvm/gems/ruby-2.3.1/gems/activerecord-4.2.5.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:438:in `new_connection'
from /usr/local/rvm/gems/ruby-2.3.1/gems/activerecord-4.2.5.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:448:in `checkout_new_connection'
from /usr/local/rvm/gems/ruby-2.3.1/gems/activerecord-4.2.5.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:422:in `acquire_connection'
from /usr/local/rvm/gems/ruby-2.3.1/gems/activerecord-4.2.5.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:349:in `block in checkout'
from /usr/local/rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/monitor.rb:214:in `mon_synchronize'
from /usr/local/rvm/gems/ruby-2.3.1/gems/activerecord-4.2.5.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:348:in `checkout'
from /usr/local/rvm/gems/ruby-2.3.1/gems/activerecord-4.2.5.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:263:in `block in connection'
from /usr/local/rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/monitor.rb:214:in `mon_synchronize'
from /usr/local/rvm/gems/ruby-2.3.1/gems/activerecord-4.2.5.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:262:in `connection'
from /usr/local/rvm/gems/ruby-2.3.1/gems/activerecord-4.2.5.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:571:in `retrieve_connection'
... 22 levels...
from /usr/local/rvm/gems/ruby-2.3.1/gems/railties-4.2.5.2/lib/rails/commands/console.rb:9:in `start'
from /usr/local/rvm/gems/ruby-2.3.1/gems/railties-4.2.5.2/lib/rails/commands/commands_tasks.rb:68:in `console'
from /usr/local/rvm/gems/ruby-2.3.1/gems/railties-4.2.5.2/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /usr/local/rvm/gems/ruby-2.3.1/gems/railties-4.2.5.2/lib/rails/commands.rb:17:in `<top (required)>'
from /usr/local/rvm/gems/ruby-2.3.1/gems/activesupport-4.2.5.2/lib/active_support/dependencies.rb:274:in `require'
from /usr/local/rvm/gems/ruby-2.3.1/gems/activesupport-4.2.5.2/lib/active_support/dependencies.rb:274:in `block in require'
from /usr/local/rvm/gems/ruby-2.3.1/gems/activesupport-4.2.5.2/lib/active_support/dependencies.rb:240:in `load_dependency'
from /usr/local/rvm/gems/ruby-2.3.1/gems/activesupport-4.2.5.2/lib/active_support/dependencies.rb:274:in `require'
from /home/rails/skreem-ror/bin/rails:9:in `<top (required)>'
from /usr/local/rvm/gems/ruby-2.3.1/gems/activesupport-4.2.5.2/lib/active_support/dependencies.rb:268:in `load'
from /usr/local/rvm/gems/ruby-2.3.1/gems/activesupport-4.2.5.2/lib/active_support/dependencies.rb:268:in `block in load'
from /usr/local/rvm/gems/ruby-2.3.1/gems/activesupport-4.2.5.2/lib/active_support/dependencies.rb:240:in `load_dependency'
from /usr/local/rvm/gems/ruby-2.3.1/gems/activesupport-4.2.5.2/lib/active_support/dependencies.rb:268:in `load'
from /usr/local/rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/local/rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
我在环境变量中设置了密码。关于如何改变它的任何解决方案?
rails@skreem-production:~/skreem-ror$ rails c production
Running via Spring preloader in process 6158
Loading production environment (Rails 4.2.5.2)
2.3.1 :001 > Rails.env
=> "production"
2.3.1 :002 > Rails.application.config.database_configuration[Rails.env]
=> {"adapter"=>"postgresql", "encoding"=>"unicode", "pool"=>5, "host"=>"localhost", "username"=>"rails", "password"=>nil, "database"=>"skreem_production"}
2.3.1 :003 >