我认为这是一个常见问题,但是我尝试了几篇其他帖子中提到的方法,却遇到了相同的命运。
我使用rbenv是因为这是我最先发现的。
rake db:create
/Users/cmunger/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/connection_adapters/connection_specification.rb:177:in `rescue in spec'
/Users/cmunger/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/connection_adapters/connection_specification.rb:174:in `spec'
/Users/cmunger/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/connection_handling.rb:50:in `establish_connection'
/Users/cmunger/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/tasks/mysql_database_tasks.rb:8:in `establish_connection'
/Users/cmunger/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/tasks/mysql_database_tasks.rb:15:in `create'
/Users/cmunger/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/tasks/database_tasks.rb:93:in `create'
/Users/cmunger/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/tasks/database_tasks.rb:107:in `block in create_current'
/Users/cmunger/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/tasks/database_tasks.rb:275:in `block in each_current_configuration'
/Users/cmunger/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/tasks/database_tasks.rb:274:in `each'
/Users/cmunger/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/tasks/database_tasks.rb:274:in `each_current_configuration'
/Users/cmunger/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/tasks/database_tasks.rb:106:in `create_current'
/Users/cmunger/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/railties/databases.rake:17:in `block (2 levels) in <top (required)>'
/Users/cmunger/.rbenv/versions/2.2.3/lib/ruby/2.2.0/rake/task.rb:240:in `call'
/Users/cmunger/.rbenv/versions/2.2.3/lib/ruby/2.2.0/rake/task.rb:240:in `block in execute'
/Users/cmunger/.rbenv/versions/2.2.3/lib/ruby/2.2.0/rake/task.rb:235:in `each'
/Users/cmunger/.rbenv/versions/2.2.3/lib/ruby/2.2.0/rake/task.rb:235:in `execute'
/Users/cmunger/.rbenv/versions/2.2.3/lib/ruby/2.2.0/rake/task.rb:179:in `block in invoke_with_call_chain'
/Users/cmunger/.rbenv/versions/2.2.3/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/Users/cmunger/.rbenv/versions/2.2.3/lib/ruby/2.2.0/rake/task.rb:172:in `invoke_with_call_chain'
/Users/cmunger/.rbenv/versions/2.2.3/lib/ruby/2.2.0/rake/task.rb:165:in `invoke'
/Users/cmunger/.rbenv/versions/2.2.3/lib/ruby/2.2.0/rake/application.rb:150:in `invoke_task'
/Users/cmunger/.rbenv/versions/2.2.3/lib/ruby/2.2.0/rake/application.rb:106:in `block (2 levels) in top_level'
/Users/cmunger/.rbenv/versions/2.2.3/lib/ruby/2.2.0/rake/application.rb:106:in `each'
/Users/cmunger/.rbenv/versions/2.2.3/lib/ruby/2.2.0/rake/application.rb:106:in `block in top_level'
/Users/cmunger/.rbenv/versions/2.2.3/lib/ruby/2.2.0/rake/application.rb:115:in `run_with_threads'
/Users/cmunger/.rbenv/versions/2.2.3/lib/ruby/2.2.0/rake/application.rb:100:in `top_level'
/Users/cmunger/.rbenv/versions/2.2.3/lib/ruby/2.2.0/rake/application.rb:78:in `block in run'
/Users/cmunger/.rbenv/versions/2.2.3/lib/ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling'
/Users/cmunger/.rbenv/versions/2.2.3/lib/ruby/2.2.0/rake/application.rb:75:in `run'
/Users/cmunger/.rbenv/versions/2.2.3/bin/rake:33:in `<main>'
Couldn't create database for {"adapter"=>"mysql2", "encoding"=>"utf8", "pool"=>5, "username"=>"blogApp", "password"=>"*****", "socket"=>"/tmp/mysql.sock", "database"=>"blog_test"}
rake aborted!
Gem::LoadError: Specified 'mysql2' for database adapter, but the gem is not loaded. Add `gem 'mysql2'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord).
Gem::LoadError: can't activate mysql2 (~> 0.3.13), already activated mysql2-0.4.2. Make sure all dependencies are added to Gemfile
我的版本和Bundle安装程序。mysql2已经存在...
cmunger@Claytons-Mac:~/Desktop/Devlopment/blog$ rbenv versions
system
* 2.2.3 (set by RBENV_VERSION environment variable)
cmunger@Claytons-Mac:~/Desktop/Devlopment/blog$ bundle install
Using actionmailer 4.2.4
Using actionpack 4.2.4
Using actionview 4.2.4
Using activejob 4.2.4
Using activemodel 4.2.4
Using activerecord 4.2.4
Using activesupport 4.2.4
Using arel 6.0.3
Using binding_of_caller 0.7.2
Using builder 3.2.2
Using bundler 1.10.6
Using byebug 8.2.1
Using coffee-rails 4.1.0
Using coffee-script 2.4.1
Using coffee-script-source 1.10.0
Using concurrent-ruby 1.0.0
Using debug_inspector 0.0.2
Using erubis 2.7.0
Using execjs 2.6.0
Using globalid 0.3.6
Using i18n 0.7.0
Using jbuilder 2.3.2
Using jquery-rails 4.0.5
Using json 1.8.3
Using loofah 2.0.3
Using mail 2.6.3
Using mime-types 2.99
Using mini_portile2 2.0.0
Using minitest 5.8.3
Using multi_json 1.11.2
Using mysql2 0.4.2
Using nokogiri 1.6.7
Using rack 1.6.4
Using rack-test 0.6.3
Using rails 4.2.4
Using rails-deprecated_sanitizer 1.0.3
Using rails-dom-testing 1.0.7
Using rails-html-sanitizer 1.0.2
Using railties 4.2.4
Using rake 10.4.2
Using rdoc 4.2.0
Using sass 3.4.20
Using sass-rails 5.0.4
Using sdoc 0.4.1
Using spring 1.5.0
Using sprockets 3.5.2
Using sprockets-rails 2.3.3
Using thor 0.19.1
Using thread_safe 0.3.5
Using tilt 2.0.1
Using turbolinks 2.5.3
Using tzinfo 1.2.2
Using uglifier 2.7.2
Using web-console 2.2.1
Bundle complete! 12 Gemfile dependencies, 54 gems now installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.
我认为以下错误可能是问题的根源:
我认为以下错误可能是问题的根源:
Gem::LoadError: can't activate mysql2 (~> 0.3.13), already activated mysql2-0.4.2. Make sure all dependencies are added to Gemfile
我尝试将其改回,但我得到了以下内容:
gem 'mysql2', '~> 0.4.2'
ERROR: While executing gem ... (Gem::CommandLineError)
Unknown command mysql2,
如果您需要任何进一步的信息,请随时询问。我是按照使用rbenv安装的维基百科上的指导进行操作的,现在进行到这个阶段了。
Gemfile
中添加mysql2
宝石,然后运行bundle install
。 - Yury Lebedevgem' mysql2'
添加到您的Gemfile中(并确保其版本至少符合ActiveRecord所需的最低要求)。Gem :: LoadError:无法激活mysql2(〜> 0.3.13),已经激活mysql2-0.4.2。确保将所有依赖项添加到Gemfile中。 - Kirs Kringle