rails db:create错误
今天用rails连接mysql后,rake db:create出现这个错误
Couldn't create database for {"adapter"=>"mysql2", "encoding"=>"utf8", "pool"=>5, "username"=>"root", "password"=>nil, "socket"=>"/var/run/mysqld/mysqld.sock", "database"=>"myblog_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).
但是查看project的gemfile后发现已有gemfile,后来经过查看资料发现因为rails版本太新,mysql2的gemfile 不配套 ,所以产生了这个错误。只需要在gemfiel中 把mysql2指定版本即可
gem 'mysql2', '~> 0.3.18'
参考网址:http://stackoverflow.com/questions/22932282/gemloaderror-specified-mysql2-for-database-adapter-but-the-gem-is-not-loade#