Sunday, July 24, 2011

Install mysql2 gem on windows

If you are trying out the Rails 3 and you are stuck at not being able to install mysql2 gem on your windows pc. Just follow this steps to install it successfully (I used MySQL 5.5.9 version):

  • Install MySQL 5.5.9
  • Copy libmysql.dll from C:\Program Files (x86)\MySQL\MySQL Server 5.5\lib [Mine was 64 bit windows, in 32 bit it must be Program Files only] to bin directory of your Ruby installation
  • Now open command prompt and run the following command: gem install mysql2 -- '--with-mysql-include="C:\Program Files (x86)\MySQL\MySQL Server 5.5\include" --with-mysql-lib="C:\Program Files (x86)\MySQL\MySQL Server 5.5\lib"'
Now its installed on was only about the extra config options and a bit of string escaping issue on windows command prompt...happy coding...  :)


  1. Ashif, I had to specify the gem version 0.2.6 to make that workable.

  2. Yes, you can install the version 0.2.6 without any problem on windows. But if you are going to install the latest one you may follow this.