Install mysql2 gem on windows

I spent almost an entire evening to find out why I couldn’t install the mysql2 gem on my windows 8.1. Don’t know if it’s easier with previous windows but I’ll show you how I did it.

A bundle install gave me this

First, you need to install mysql libraries packaged with mysql-server installer. You’ll need them to compile the gem afterwards. Choose the mysql version 32bits or 64-bits depending on what you version of ruby you installed for a better compatibility. 32bits version of  mysql is in Program Files (x86). if you choose 64bits version, mysql is in Program Files.

I installed mysql 5.5 32bits, download is here Windows (x86, 32-bit), MSI Installer. I configured and checked the Add Mysql Bin Folder to PATH box.

Now you’re going to install the gem in a command window and type:

Then copy the libmysql.dll found in C:\Program Files (x86)\MySQL\MySQL Server 5.5\lib to your ruby bin folder C:\Ruby200\bin

For your information, here is a short example of mysql2 database implementation in config/database.yml :

To learn how to deal with ActiveRecord and MySQL: Active Record Query Interface Tutorial

 

Leave a Reply

Your email address will not be published. Required fields are marked *

Post Navigation