ihatov08 blog

プログラミング初心者だけどRailsとSwiftマスターします

railsでmysqlのエラーが起きた時の対処法

bin/rake db:create

エラーが起きる

/home/vagrant/.gem/ruby/2.1.0/gems/activerecord-4.1.0/lib/active_record/connection_adapters/connection_specification.rb:190:in `rescue in spec': 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)

gemfileでmysqlのバージョンを指定する。 mysqlのバージョンは指定しておいた方がいい。

gemfile
gem 'mysql2', '~> 0.3.13'
bin/bundle update mysql2

もう一度データベースを作成する。

bin/rake db:create