Rake db:创建错误,找不到解决方案

时间:2015-11-09 07:10:32

标签: ruby-on-rails ruby ruby-on-rails-3 gem mysql2

c:\row\dev\hello_world>db:create
The filename, directory name, or volume label syntax is incorrect.

c:\row\dev\hello_world>rake db:create
c:/row/Ruby200/lib/ruby/gems/2.2.0/gems/activesupport-4.0.2/lib/active_support/values/time_zone.rb:282: warning: circular argument reference - now
Specified 'mysql2' for database adapter, but the gem is not loaded. Add `gem 'mysql2'` to your Gemfile.
c:/row/Ruby200/lib/ruby/gems/2.2.0/gems/activerecord-4.0.2/lib/active_record/connection_adapters/connection_specification.rb:58:in `rescue in resolve_hash_connection'
c:/row/Ruby200/lib/ruby/gems/2.2.0/gems/activerecord-4.0.2/lib/active_record/connection_adapters/connection_specification.rb:55:in `resolve_hash_connection'
c:/row/Ruby200/lib/ruby/gems/2.2.0/gems/activerecord-4.0.2/lib/active_record/connection_adapters/connection_specification.rb:34:in `spec'
c:/row/Ruby200/lib/ruby/gems/2.2.0/gems/activerecord-4.0.2/lib/active_record/connection_handling.rb:39:in `establish_connection'
c:in `establish_connection'
c:/row/Ruby200/lib/ruby/gems/2.2.0/gems/activerecord-4.0.2/lib/active_record/tasks/mysql_database_tasks.rb:15:in `create'
c:/row/Ruby200/lib/ruby/gems/2.2.0/gems/activerecord-4.0.2/lib/active_record/tasks/database_tasks.rb:73:in `create'
c:/row/Ruby200/lib/ruby/gems/2.2.0/gems/activerecord-4.0.2/lib/active_record/tasks/database_tasks.rb:87:in `block in create_current'
c:/row/Ruby200/lib/ruby/gems/2.2.0/gems/activerecord-4.0.2/lib/active_record/tasks/database_tasks.rb:183:in `block in each_current_configuration'
c:/row/Ruby200/lib/ruby/gems/2.2.0/gems/activerecord-4.0.2/lib/active_record/tasks/database_tasks.rb:182:in `each'
c:/row/Ruby200/lib/ruby/gems/2.2.0/gems/activerecord-4.0.2/lib/active_record/tasks/database_tasks.rb:182:in `each_current_configuration'
c:/row/Ruby200/lib/ruby/gems/2.2.0/gems/activerecord-4.0.2/lib/active_record/tasks/database_tasks.rb:86:in `create_current'
c:/row/Ruby200/lib/ruby/gems/2.2.0/gems/activerecord-4.0.2/lib/active_record/railties/databases.rake:20:in `block (2 levels) in <top (required)>'
c:/row/Ruby200/lib/ruby/2.2.0/rake/task.rb:240:in `call'
c:/row/Ruby200/lib/ruby/2.2.0/rake/task.rb:240:in `block in execute'
c:/row/Ruby200/lib/ruby/2.2.0/rake/task.rb:235:in `each'
c:/row/Ruby200/lib/ruby/2.2.0/rake/task.rb:235:in `execute'
c:/row/Ruby200/lib/ruby/2.2.0/rake/task.rb:179:in `block in invoke_with_call_chain'
c:/row/Ruby200/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
c:/row/Ruby200/lib/ruby/2.2.0/rake/task.rb:172:in `invoke_with_call_chain'
c:/row/Ruby200/lib/ruby/2.2.0/rake/task.rb:165:in `invoke'
c:/row/Ruby200/lib/ruby/2.2.0/rake/application.rb:150:in `invoke_task'
c:/row/Ruby200/lib/ruby/2.2.0/rake/application.rb:106:in `block (2 levels) in top_level'
c:/row/Ruby200/lib/ruby/2.2.0/rake/application.rb:106:in `each'
c:/row/Ruby200/lib/ruby/2.2.0/rake/application.rb:106:in `block in top_level'
c:/row/Ruby200/lib/ruby/2.2.0/rake/application.rb:115:in `run_with_threads'
c:/row/Ruby200/lib/ruby/2.2.0/rake/application.rb:100:in `top_level'
c:/row/Ruby200/lib/ruby/2.2.0/rake/application.rb:78:in `block in run'
c:/row/Ruby200/lib/ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling'
c:/row/Ruby200/lib/ruby/2.2.0/rake/application.rb:75:in `run'
c:/row/Ruby200/bin/rake:33:in `<main>'
Couldn't create database for {"adapter"=>"mysql2", "encoding"=>"utf8", "database"=>"hello_world_development", "pool"=>5, "username"=>"root", "password"=>"axel24", "host"=>"localhost"}
Specified 'mysql2' for database adapter, but the gem is not loaded. Add `gem 'mysql2'` to your Gemfile.
c:/row/Ruby200/lib/ruby/gems/2.2.0/gems/activerecord-4.0.2/lib/active_record/connection_adapters/connection_specification.rb:58:in `rescue in resolve_hash_connection'
c:/row/Ruby200/lib/ruby/gems/2.2.0/gems/activerecord-4.0.2/lib/active_record/connection_adapters/connection_specification.rb:55:in `resolve_hash_connection'
c:/row/Ruby200/lib/ruby/gems/2.2.0/gems/activerecord-4.0.2/lib/active_record/connection_adapters/connection_specification.rb:34:in `spec'
c:/row/Ruby200/lib/ruby/gems/2.2.0/gems/activerecord-4.0.2/lib/active_record/connection_handling.rb:39:in `establish_connection'
c:in `establish_connection'
c:/row/Ruby200/lib/ruby/gems/2.2.0/gems/activerecord-4.0.2/lib/active_record/tasks/mysql_database_tasks.rb:15:in `create'
c:/row/Ruby200/lib/ruby/gems/2.2.0/gems/activerecord-4.0.2/lib/active_record/tasks/database_tasks.rb:73:in `create'
c:/row/Ruby200/lib/ruby/gems/2.2.0/gems/activerecord-4.0.2/lib/active_record/tasks/database_tasks.rb:87:in `block in create_current'
c:/row/Ruby200/lib/ruby/gems/2.2.0/gems/activerecord-4.0.2/lib/active_record/tasks/database_tasks.rb:183:in `block in each_current_configuration'
c:/row/Ruby200/lib/ruby/gems/2.2.0/gems/activerecord-4.0.2/lib/active_record/tasks/database_tasks.rb:182:in `each'
c:/row/Ruby200/lib/ruby/gems/2.2.0/gems/activerecord-4.0.2/lib/active_record/tasks/database_tasks.rb:182:in `each_current_configuration'
c:/row/Ruby200/lib/ruby/gems/2.2.0/gems/activerecord-4.0.2/lib/active_record/tasks/database_tasks.rb:86:in `create_current'
c:/row/Ruby200/lib/ruby/gems/2.2.0/gems/activerecord-4.0.2/lib/active_record/railties/databases.rake:20:in `block (2 levels) in <top (required)>'
c:/row/Ruby200/lib/ruby/2.2.0/rake/task.rb:240:in `call'
c:/row/Ruby200/lib/ruby/2.2.0/rake/task.rb:240:in `block in execute'
c:/row/Ruby200/lib/ruby/2.2.0/rake/task.rb:235:in `each'
c:/row/Ruby200/lib/ruby/2.2.0/rake/task.rb:235:in `execute'
c:/row/Ruby200/lib/ruby/2.2.0/rake/task.rb:179:in `block in invoke_with_call_chain'
c:/row/Ruby200/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
c:/row/Ruby200/lib/ruby/2.2.0/rake/task.rb:172:in `invoke_with_call_chain'
c:/row/Ruby200/lib/ruby/2.2.0/rake/task.rb:165:in `invoke'
c:/row/Ruby200/lib/ruby/2.2.0/rake/application.rb:150:in `invoke_task'
c:/row/Ruby200/lib/ruby/2.2.0/rake/application.rb:106:in `block (2 levels) in top_level'
c:/row/Ruby200/lib/ruby/2.2.0/rake/application.rb:106:in `each'
c:/row/Ruby200/lib/ruby/2.2.0/rake/application.rb:106:in `block in top_level'
c:/row/Ruby200/lib/ruby/2.2.0/rake/application.rb:115:in `run_with_threads'
c:/row/Ruby200/lib/ruby/2.2.0/rake/application.rb:100:in `top_level'
c:/row/Ruby200/lib/ruby/2.2.0/rake/application.rb:78:in `block in run'
c:/row/Ruby200/lib/ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling'
c:/row/Ruby200/lib/ruby/2.2.0/rake/application.rb:75:in `run'
c:/row/Ruby200/bin/rake:33:in `<main>'
Couldn't create database for {"adapter"=>"mysql2", "encoding"=>"utf8", "database"=>"hello_world_test", "pool"=>5, "username"=>"root", "password"=>"axel24", "host"=>"localhost"}
rake aborted!
**Gem::LoadError: Specified 'mysql2' for database adapter, but the gem is not loaded. Add `gem 'mysql2'` to your Gemfile.
Gem::LoadError: can't activate mysql2 (~> 0.3.18), already activated mysql2-0.4.1-x86-mingw32. Make sure all dependencies are added to Gemfile.**

Tasks: TOP => db:create
(See full trace by running task with --trace)

1 个答案:

答案 0 :(得分:1)

错误消息非常具体。他们多次告诉你:

**Gem::LoadError: Specified 'mysql2' for database adapter, but the gem is not loaded. Add `gem 'mysql2'` to your Gemfile.

gem 'mysql2'添加到Gemfile并运行:

bundle install

试。