Ruby, Windows and MySQL
Not quite a happy family, let’s try to fix that shall we.
I always like to make sure I have the latest RubyGems installed, so let’s do that now by running the following command:
gem update --system
Now that we have the latest RubyGems, lets install the gem that will allow us to connect to MySQL servers with Ruby.
The best gem is the
mysql2 gem, at least in m opinion, but first we need to grab the MySQL C Connector source. You will need to download the “Windows (x86, 32-bit), ZIP Archive” to install the gem.
Now extract it to the
c:\mysqlconnector, this will make things easier.
libmysql.dll file from
c:\mysqlconnector\lib to the “bin” directory in your Ruby install directory, mine was
Now we can install the gem, run the following command:
gem install mysql2 -- '--with-mysql-lib="C:\mysqlconnector\lib" --with-mysql-include="C:\mysqlconnector\include"'
Hopefully this works just as well as it did for me and the mysql2 gem is now installed.