How to resolve the error 'fe_sendauth: no password supplied' in Rails using PostgreSQL?
我试图用postgresql数据库创建我的Rails应用程序,但是当我启动
fe_sendauth: no password supplied
这是我一步一步的行动:
1 2 3 | $ sudo apt-GET install postgresql postgresql-contrib $ gem install pg $ rails NEW timetracker --database=postgresql --skip-unit-test |
我的
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | DEFAULT: &DEFAULT adapter: postgresql encoding: unicode pool: 5 host: localhost username: postgres password: development: <<: *DEFAULT DATABASE: timetracker_development test: <<: *DEFAULT DATABASE: timetracker_test production: <<: *DEFAULT DATABASE: timetracker_production |
这是我的
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | # DATABASE administrative login BY Unix DOMAIN socket LOCAL ALL postgres peer # TYPE DATABASE USER ADDRESS METHOD #"local" IS FOR Unix DOMAIN socket connections ONLY LOCAL ALL ALL peer # IPv4 LOCAL connections: host ALL ALL 127.0.0.1/32 md5 # IPv6 LOCAL connections: host ALL ALL ::1/128 md5 # modified BY me. host ALL ALL 127.0.0.1/32 trust host ALL ALL 127.0.0.1/32 trust host ALL ALL ::1/128 trust |
所以,当我做
1 2 | $ rails c $ ActiveRecord::Base.connection.instance_variable_get(:@config) |
2.1.5 :001 > ActiveRecord::Base.connection.instance_variable_get(:@config)
PG::ConnectionBad: fe_sendauth: no password suppliedfrom
/home/denis/.rvm/gems/ruby-2.1.5/gems/activerecord-4.2.3/lib/active_record/connection_adapters/postgresql_adapter.rb:655:ininitialize' from new' from
/home/denis/.rvm/gems/ruby-2.1.5/gems/activerecord-4.2.3/lib/active_record/connection_adapters/postgresql_adapter.rb:655:in
/home/denis/.rvm/gems/ruby-2.1.5/gems/activerecord-4.2.3/lib/active_record/connection_adapters/postgresql_adapter.rb:655:inconnect' from initialize' from
/home/denis/.rvm/gems/ruby-2.1.5/gems/activerecord-4.2.3/lib/active_record/connection_adapters/postgresql_adapter.rb:242:in
/home/denis/.rvm/gems/ruby-2.1.5/gems/activerecord-4.2.3/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in
new' from postgresql_connection' from
/home/denis/.rvm/gems/ruby-2.1.5/gems/activerecord-4.2.3/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in
/home/denis/.rvm/gems/ruby-2.1.5/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:438:in
new_connection' from checkout_new_connection' from
/home/denis/.rvm/gems/ruby-2.1.5/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:448:in
/home/denis/.rvm/gems/ruby-2.1.5/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:422:in
acquire_connection' from block in checkout' from
/home/denis/.rvm/gems/ruby-2.1.5/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:349:in
/home/denis/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/monitor.rb:211:in
mon_synchronize' from checkout' from
/home/denis/.rvm/gems/ruby-2.1.5/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:348:in
/home/denis/.rvm/gems/ruby-2.1.5/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:263:in
block in connection' from mon_synchronize' from
/home/denis/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/monitor.rb:211:in
/home/denis/.rvm/gems/ruby-2.1.5/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:262:in
connection' from retrieve_connection' ... 4 levels... from
/home/denis/.rvm/gems/ruby-2.1.5/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:571:in
/home/denis/.rvm/gems/ruby-2.1.5/gems/railties-4.2.3/lib/rails/commands/console.rb:9:in
start' from console' from
/home/denis/.rvm/gems/ruby-2.1.5/gems/railties-4.2.3/lib/rails/commands/commands_tasks.rb:68:in
/home/denis/.rvm/gems/ruby-2.1.5/gems/railties-4.2.3/lib/rails/commands/commands_tasks.rb:39:in
run_command!' from ' from
/home/denis/.rvm/gems/ruby-2.1.5/gems/railties-4.2.3/lib/rails/commands.rb:17:in
/home/denis/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:274:inrequire' from block in require' from
/home/denis/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:274:in
/home/denis/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:240:inload_dependency' from require' from /home/denis/WEB/Rails/timetracker/bin/rails:8:in
/home/denis/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:274:inload' from ' from
/home/denis/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:268:in
/home/denis/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:268:inblock in load' from load_dependency' from
/home/denis/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:240:in
/home/denis/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:268:inload' from require' from
/home/denis/.rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in
/home/denis/.rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:inrequire' from -e:1:in '2.1.5 :002 >
我第一次使用postgresql,我想我只是做错了。
你能帮帮我吗?
我对此问题的解决方案是从
PostgreSQL按照指定的顺序匹配
将自定义