Please install mysql adapter 'gem install activerecord-mysql-adapter'

前端 未结 16 1403
挽巷
挽巷 2020-12-28 12:23

I\'m having trouble finding a solution to this problem. I\'m getting the error:

Please install the mysql adapter: \'gem install activerecord-mysql-adapter\'
         


        
相关标签:
16条回答
  • 2020-12-28 12:58

    you have mentioned your database.yaml file already has mysql2.

    Its worth checking if you have activerecord-mysql2-adapter installed. (Note -mysql2- )

    0 讨论(0)
  • 2020-12-28 12:59

    I never would have believed it but deleting my database.yml file and recreating it actually solved the problem for me too. Thanks Tyler. I spent hours installing and uninstalling different versions of the gems mysql, mysql2, activerecord-mysql-adapter, etc... In the end, my gemfile has

    gem 'mysql2', "~>0.3.11"
    

    and my database.yml file has

    adapter: mysql2
    

    I am on OSX 10.8, rails 3.2.8, and ruby 1.9.3.

    By the way, I experienced the same issues with the mysql2 adapter on my Windows 7 machine. Uninstalling and even deleting the directory for the activerecord-mysql-adapter gem seemed to be critical as well.

    0 讨论(0)
  • 2020-12-28 12:59

    You want to install the mysql2 gem.

    Really, you should probably add it to your Gemfile:

    gem "mysql2"
    

    And then install your gems with bundler:

    bundle install
    
    0 讨论(0)
  • 2020-12-28 13:00

    I just added the following line to my Gemfile an it worked:

    gem "mysql"

    Before:

    source 'https://rubygems.org'
    
    gem "rails", "3.2.16"
    gem "jquery-rails", "~> 2.0.2"
    gem "coderay", "~> 1.1.0"
    gem "fastercsv", "~> 1.5.0", :platforms => [:mri_18, :mingw_18, :jruby]
    gem "builder", "3.0.0"
    ...
    

    After:

    source 'https://rubygems.org'
    
    gem "mysql"
    gem "rails", "3.2.16"
    gem "jquery-rails", "~> 2.0.2"
    gem "coderay", "~> 1.1.0"
    gem "fastercsv", "~> 1.5.0", :platforms => [:mri_18, :mingw_18, :jruby]
    gem "builder", "3.0.0"
    ...
    
    0 讨论(0)
  • 2020-12-28 13:05

    I had the same problem as OP on OSX Lion after upgrading to Rails 3.2. Removing all gems, bundle install, etc did not work. Gemfile and database.yml were correctly specifying mysql2.

    In the end, I deleted and recreated my database.yml and everything works again. It was probably a typo or hidden character in the file.

    0 讨论(0)
  • 2020-12-28 13:05

    In my case, when I also got this error:

    rake aborted! Please install the mysql adapter: gem install activerecord-mysql-adapter (mysql is not part of the bundle. Add it to Gemfile.)

    After I searched Google and tried many ways, it didn't work. Finally, the answer is

    • Navigate to the root of your app, run open gemfile
    • Add the line gem 'mysql2', '< 0.3.7' directly below the gem line for rails.
    0 讨论(0)
提交回复
热议问题