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

前端 未结 16 1404
挽巷
挽巷 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 13:06

    1) You need to update your config/database.yml file and change:

    adapter: mysql
    

    into

    adapter: mysql2
    

    2) You need to update your Gemfile and explicitly add activerecord-mysql2-adapter dependency there:

    gem 'mysql2'
    gem 'activerecord-mysql2-adapter'
    
    0 讨论(0)
  • 2020-12-28 13:07

    I would say that change the commented information on top in database.yml to

    # 
    # Install the MYSQL driver
    #   gem install mysql2
    #
    # Ensure the MySQL gem is defined in your Gemfile
    #   gem 'mysql2'
    #
    # And be sure to use new-style password hashing:
    #   http://dev.mysql.com/doc/refman/5.0/en/old-client.html
    

    second: add " gem 'mysql2' " (what ever is inside the double quotation marks) to gemfile .

    save everything, do bundle install. Hope that helps.

    or it just could be a typo.

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

    I am facing the same issue and getting same error when run command

    gem install activerecord-mysql2-adapter
    

    you need to install libmysqlclient-dev

    sudo apt-get install libmysqlclient-dev
    

    It works for me

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

    It is possible that you have changed adapter to mysql2 for a certain environment only but are not passing the environment to the rake command.

    E.g. I only changed mysql to mysql2 on the production environment but was running

    rake generate_secret_token
    

    when I changed it to the following it worked:

    rake generate_secret_token RAILS_ENV=production
    
    0 讨论(0)
提交回复
热议问题