Gem::LoadError for mysql2 gem, but it's already in Gemfile

后端 未结 14 2619
醉酒成梦
醉酒成梦 2020-12-02 08:35
Gem::LoadError
Specified \'mysql2\' for database adapter, but the gem is not loaded.
Add `gem \'mysql2\'` to your Gemfile

This error occurred while

14条回答
  •  隐瞒了意图╮
    2020-12-02 08:56

    This issue may occur if you're using newer version of rails > 4

    Do these two simple steps, it will work. Open your Gemfile and find the below line

    gem 'mysql2'
    

    replace that line with a specific mysql version like below

    gem 'mysql2', '~> 0.3.18'
    

    Now stop the server and run bundle

    bundle install
    

    Now restart your server. It should work.

    rails s
    

提交回复
热议问题