You are here

Rails 2.2.2 and MySQL 5.X in Windows issue - cannot migrate

Just formatted my machine and had to reinstall all my development environment in Windows 7. I ran into a problem that I never had before. After successfully installing MySQL 5.1, Ruby 1.8.6 and Rails 2.2.2 (I need those in these exact versions, because this is what my hosting service supports) I tried to migrate my database and the problems began.
After running "rake db:migrate" I got this error message:

!!! The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql.
rake aborted!
126: The specified module could not be found.


Then I thought: "Ok, the answer to the problem is right there. Let's run the 'gem install mysql' command and everything shall be fine." So I typed:

gem install mysql


Note: It actually might be better to avoid the error messages. This has no effect on the end result but it shows a tidier command result. So run this:

gem install mysql --no-rdoc --no-ri
Successfully installed mysql-2.8.1-x86-mswin32
1 gem installed


But imagine my surprise when I ran "rake db:migrate" again and got the same error message again. And then the googling started and I found the solution.
The reason is that Rails 2.2 in incompatible with MySQL 5.x client, so it is necessary to give Ruby the correct DLL to connect do MySQL.
I found a (possible) solution which is simply copying the "%MYSQL_HOME%\bin\libmySQL.dll" library into "%RUBY_HOME%\bin\libmySQL.dll". Unfortunately that did not work for me either.
Luckily the guys from Instant Rails have a version of this DLL that works. You can download it using the link below and save in the same "%RUBY_HOME%\bin\" folder.
Link: http://instantrails.rubyforge.org/svn/trunk/InstantRails-win/InstantRails/mysql/bin/libmySQL.dll

A topic in the Ruby Forum discussed this on a thread.