Jul 11, 2011

Install MySql2 properly on Windows for Rails 3

You will need to configure your Bundle to use some flags by:


bundle config build.mysql2 --with-mysql-lib="C:\xampp\mysql\lib\opt" --with-mysql-include="C:\xampp\mysql\include"


If you cannot find lib\opt and include folder, please install MySql Connector/C. The folders will be there.

Then you must use mysql2 version 0.2.6 for Windows. Other versions do not work.

In your Gemfile, you should have this:


gem 'mysql2', '0.2.6'


And then you can run:


bundle install (or update)


This will solve all your problems, including "incompatible character encodings: UTF-8 and ASCII-8BIT".