Rake db:create在服务器上给出错误

时间:2022-10-07 08:11:45

I set up my VPS using this tutorial

我使用本教程设置了我的VPS

Everything was fine until I needed manually create dabatase on server using this command:

一切都很好,直到我需要使用此命令在服务器上手动创建dabatase:

RAILS_ENV=production bundle exec rake db:create

It gives my this error:

它给出了我的错误:

    fe_sendauth: no password supplied
/home/deploy/liftme/shared/bundle/ruby/2.1.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `initialize'
/home/deploy/liftme/shared/bundle/ruby/2.1.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `new'
/home/deploy/liftme/shared/bundle/ruby/2.1.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `connect'
/home/deploy/liftme/shared/bundle/ruby/2.1.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:242:in `initialize'
/home/deploy/liftme/shared/bundle/ruby/2.1.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `new'
/home/deploy/liftme/shared/bundle/ruby/2.1.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `postgresql_connection'
/home/deploy/liftme/shared/bundle/ruby/2.1.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:436:in `new_connection'
/home/deploy/liftme/shared/bundle/ruby/2.1.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:446:in `checkout_new_connection'
/home/deploy/liftme/shared/bundle/ruby/2.1.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:422:in `acquire_connection'
/home/deploy/liftme/shared/bundle/ruby/2.1.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:349:in `block in checkout'
/home/deploy/.rbenv/versions/2.1.5/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
/home/deploy/liftme/shared/bundle/ruby/2.1.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:348:in `checkout'
/home/deploy/liftme/shared/bundle/ruby/2.1.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:263:in `block in connection'
/home/deploy/.rbenv/versions/2.1.5/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
/home/deploy/liftme/shared/bundle/ruby/2.1.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:262:in `connection'
/home/deploy/liftme/shared/bundle/ruby/2.1.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:565:in `retrieve_connection'
/home/deploy/liftme/shared/bundle/ruby/2.1.0/gems/activerecord-4.2.0/lib/active_record/connection_handling.rb:113:in `retrieve_connection'
/home/deploy/liftme/shared/bundle/ruby/2.1.0/gems/activerecord-4.2.0/lib/active_record/connection_handling.rb:87:in `connection'
/home/deploy/liftme/shared/bundle/ruby/2.1.0/gems/activerecord-4.2.0/lib/active_record/tasks/postgresql_database_tasks.rb:8:in `connection'
/home/deploy/liftme/shared/bundle/ruby/2.1.0/gems/activerecord-4.2.0/lib/active_record/tasks/postgresql_database_tasks.rb:17:in `create'
/home/deploy/liftme/shared/bundle/ruby/2.1.0/gems/activerecord-4.2.0/lib/active_record/tasks/database_tasks.rb:93:in `create'
/home/deploy/liftme/shared/bundle/ruby/2.1.0/gems/activerecord-4.2.0/lib/active_record/tasks/database_tasks.rb:107:in `block in create_current'
/home/deploy/liftme/shared/bundle/ruby/2.1.0/gems/activerecord-4.2.0/lib/active_record/tasks/database_tasks.rb:275:in `block in each_current_configuration'
/home/deploy/liftme/shared/bundle/ruby/2.1.0/gems/activerecord-4.2.0/lib/active_record/tasks/database_tasks.rb:274:in `each'
/home/deploy/liftme/shared/bundle/ruby/2.1.0/gems/activerecord-4.2.0/lib/active_record/tasks/database_tasks.rb:274:in `each_current_configuration'
/home/deploy/liftme/shared/bundle/ruby/2.1.0/gems/activerecord-4.2.0/lib/active_record/tasks/database_tasks.rb:106:in `create_current'
/home/deploy/liftme/shared/bundle/ruby/2.1.0/gems/activerecord-4.2.0/lib/active_record/railties/databases.rake:17:in `block (2 levels) in <top (required)>'
/home/deploy/liftme/shared/bundle/ruby/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:240:in `call'
/home/deploy/liftme/shared/bundle/ruby/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:240:in `block in execute'
/home/deploy/liftme/shared/bundle/ruby/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:235:in `each'
/home/deploy/liftme/shared/bundle/ruby/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:235:in `execute'
/home/deploy/liftme/shared/bundle/ruby/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
/home/deploy/.rbenv/versions/2.1.5/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
/home/deploy/liftme/shared/bundle/ruby/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:172:in `invoke_with_call_chain'
/home/deploy/liftme/shared/bundle/ruby/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:165:in `invoke'
/home/deploy/liftme/shared/bundle/ruby/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:150:in `invoke_task'
/home/deploy/liftme/shared/bundle/ruby/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/home/deploy/liftme/shared/bundle/ruby/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:106:in `each'
/home/deploy/liftme/shared/bundle/ruby/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:106:in `block in top_level'
/home/deploy/liftme/shared/bundle/ruby/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:115:in `run_with_threads'
/home/deploy/liftme/shared/bundle/ruby/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:100:in `top_level'
/home/deploy/liftme/shared/bundle/ruby/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:78:in `block in run'
/home/deploy/liftme/shared/bundle/ruby/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:176:in `standard_exception_handling'
/home/deploy/liftme/shared/bundle/ruby/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:75:in `run'
/home/deploy/liftme/shared/bundle/ruby/2.1.0/gems/rake-10.4.2/bin/rake:33:in `<top (required)>'
/home/deploy/liftme/shared/bundle/ruby/2.1.0/bin/rake:23:in `load'
/home/deploy/liftme/shared/bundle/ruby/2.1.0/bin/rake:23:in `<main>'
Couldn't create database for {"adapter"=>"postgresql", "encoding"=>"unicode", "pool"=>5, "database"=>"liftme_production"}

My production database.yml configuration:

我的生产database.yml配置:

production:
  <<: *default
  database: liftme_production
 # username: liftme
 # password: <%= ENV['LIFTME_DATABASE_PASSWORD'] %>

Even if I uncomment, it still gives me the same error.

即使我取消注释,它仍然给我同样的错误。

1 个解决方案

#1


0  

Make sure you the LIFTME_DATABASE_PASSWORD environment variable set:

确保设置了LIFTME_DATABASE_PASSWORD环境变量:

before executing your rake task do this:

在执行rake任务之前执行以下操作:

$ export LIFTME_DATABASE_PASSWORD=MyUnbreakablePassword

to make sure you have the environment variable set you can use:

要确保您拥有可以使用的环境变量集:

$ env | grep LIFTME_DATABASE_PASSWORD

Also read this blog post about managing environment variables in your rails application.

另请阅读此博客文章,了解如何在rails应用程序中管理环境变量。

#1


0  

Make sure you the LIFTME_DATABASE_PASSWORD environment variable set:

确保设置了LIFTME_DATABASE_PASSWORD环境变量:

before executing your rake task do this:

在执行rake任务之前执行以下操作:

$ export LIFTME_DATABASE_PASSWORD=MyUnbreakablePassword

to make sure you have the environment variable set you can use:

要确保您拥有可以使用的环境变量集:

$ env | grep LIFTME_DATABASE_PASSWORD

Also read this blog post about managing environment variables in your rails application.

另请阅读此博客文章,了解如何在rails应用程序中管理环境变量。