Rails + PostgreSQL:无法创建数据库 - 没有这样的数据库:postgres

时间:2015-06-17 18:18:28

标签: ruby-on-rails postgresql

我刚删除并重新克隆了我的Rails + PostgreSQL应用程序,但现在它似乎在寻找数据库postgres,尽管它没有在任何地方指定。

使用Rails 4.2和PostgreSQL 9.4。

% bundle exec rake db:create RAILS_ENV=production
ERROR:  No such database: postgres
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `initialize'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `new'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `connect'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:242:in `initialize'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `new'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `postgresql_connection'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:436:in `new_connection'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:446:in `checkout_new_connection'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:422:in `acquire_connection'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:349:in `block in checkout'
/usr/local/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:348:in `checkout'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:263:in `block in connection'
/usr/local/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:262:in `connection'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:565:in `retrieve_connection'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_handling.rb:113:in `retrieve_connection'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_handling.rb:87:in `connection'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/tasks/postgresql_database_tasks.rb:8:in `connection'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/tasks/postgresql_database_tasks.rb:30:in `drop'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/tasks/database_tasks.rb:114:in `drop'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/tasks/database_tasks.rb:128:in `block in drop_current'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/tasks/database_tasks.rb:275:in `block in each_current_configuration'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/tasks/database_tasks.rb:274:in `each'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/tasks/database_tasks.rb:274:in `each_current_configuration'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/tasks/database_tasks.rb:127:in `drop_current'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/railties/databases.rake:28:in `block (2 levels) in <top (required)>'
/usr/local/lib/ruby/2.2.0/rake/task.rb:240:in `call'
/usr/local/lib/ruby/2.2.0/rake/task.rb:240:in `block in execute'
/usr/local/lib/ruby/2.2.0/rake/task.rb:235:in `each'
/usr/local/lib/ruby/2.2.0/rake/task.rb:235:in `execute'
/usr/local/lib/ruby/2.2.0/rake/task.rb:179:in `block in invoke_with_call_chain'
/usr/local/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/usr/local/lib/ruby/2.2.0/rake/task.rb:172:in `invoke_with_call_chain'
/usr/local/lib/ruby/2.2.0/rake/task.rb:165:in `invoke'
/usr/local/lib/ruby/2.2.0/rake/application.rb:150:in `invoke_task'
/usr/local/lib/ruby/2.2.0/rake/application.rb:106:in `block (2 levels) in top_level'
/usr/local/lib/ruby/2.2.0/rake/application.rb:106:in `each'
/usr/local/lib/ruby/2.2.0/rake/application.rb:106:in `block in top_level'
/usr/local/lib/ruby/2.2.0/rake/application.rb:115:in `run_with_threads'
/usr/local/lib/ruby/2.2.0/rake/application.rb:100:in `top_level'
/usr/local/lib/ruby/2.2.0/rake/application.rb:78:in `block in run'
/usr/local/lib/ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling'
/usr/local/lib/ruby/2.2.0/rake/application.rb:75:in `run'
/home/example/bin/rake:8:in `<main>'
Couldn't drop example
example@konge:~% bundle exec rake db:create RAILS_ENV=production
ERROR:  No such database: postgres
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `initialize'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `new'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `connect'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:242:in `initialize'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `new'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `postgresql_connection'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:436:in `new_connection'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:446:in `checkout_new_connection'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:422:in `acquire_connection'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:349:in `block in checkout'
/usr/local/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:348:in `checkout'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:263:in `block in connection'
/usr/local/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:262:in `connection'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:565:in `retrieve_connection'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_handling.rb:113:in `retrieve_connection'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_handling.rb:87:in `connection'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/tasks/postgresql_database_tasks.rb:8:in `connection'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/tasks/postgresql_database_tasks.rb:17:in `create'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/tasks/database_tasks.rb:93:in `create'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/tasks/database_tasks.rb:107:in `block in create_current'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/tasks/database_tasks.rb:275:in `block in each_current_configuration'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/tasks/database_tasks.rb:274:in `each'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/tasks/database_tasks.rb:274:in `each_current_configuration'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/tasks/database_tasks.rb:106:in `create_current'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/railties/databases.rake:17:in `block (2 levels) in <top (required)>'
/usr/local/lib/ruby/2.2.0/rake/task.rb:240:in `call'
/usr/local/lib/ruby/2.2.0/rake/task.rb:240:in `block in execute'
/usr/local/lib/ruby/2.2.0/rake/task.rb:235:in `each'
/usr/local/lib/ruby/2.2.0/rake/task.rb:235:in `execute'
/usr/local/lib/ruby/2.2.0/rake/task.rb:179:in `block in invoke_with_call_chain'
/usr/local/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/usr/local/lib/ruby/2.2.0/rake/task.rb:172:in `invoke_with_call_chain'
/usr/local/lib/ruby/2.2.0/rake/task.rb:165:in `invoke'
/usr/local/lib/ruby/2.2.0/rake/application.rb:150:in `invoke_task'
/usr/local/lib/ruby/2.2.0/rake/application.rb:106:in `block (2 levels) in top_level'
/usr/local/lib/ruby/2.2.0/rake/application.rb:106:in `each'
/usr/local/lib/ruby/2.2.0/rake/application.rb:106:in `block in top_level'
/usr/local/lib/ruby/2.2.0/rake/application.rb:115:in `run_with_threads'
/usr/local/lib/ruby/2.2.0/rake/application.rb:100:in `top_level'
/usr/local/lib/ruby/2.2.0/rake/application.rb:78:in `block in run'
/usr/local/lib/ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling'
/usr/local/lib/ruby/2.2.0/rake/application.rb:75:in `run'
/home/example/bin/rake:8:in `<main>'
Couldn't create database for {"adapter"=>"postgresql", "username"=>"example", "password"=>"example1234", "database"=>"example", "port"=>6543, "prepared_statements"=>false}

的database.yml

production:
  adapter: postgresql
  username: example
  password: example1234
  database: example
  port: 6543
  prepared_statements: false

development:
  adapter: postgresql
  password: example1234
  database: example

test:
  adapter: postgresql

0 个答案:

没有答案