Install mysql2 gem on Windows 7

Last couple of days ago, I was stuck to install mysql2 gem on windows7 for rails3 and tried lots of instructions by googling. Unfortunately, those were not worked for me.

Finally, I have specified a older version of mysql2 during installation which worked for me. Following are the steps which i did:

  • Install Mysql 5.5
  • Open command prompt and run following command
    gem install mysql2 --version=0.2.6 --platform=ruby -- '--with-mysql-include="C:Program FilesMySQLMySQL Server 5.5include" --with-mysql-lib="C:Program FilesMySQLMySQL Server 5.5lib"'
  • Copy libmysql.dll from C:Program FilesMySQLMySQL Server 5.5lib to [Ruby Installation Directory]bin
  • Specify mysql2 version to you gem file
  • Run bundle install

Leave a Comment