How to fix Error installing mysql2 gem


There are so many reasons why you cannot install or use mysql2 gem successfully. Even if this solution works great for me, it might not work on you. However, this is so far the easiest fix that I found and feel free to give it it a try. Below is my setting:

  • Windows 8.1
  • Ruby 2.0.0
  • Gem 2.0.15  (you must upgrade your gem. I upgraded my gem from 2.0.14 to 2.0.15. see this post)
  • Rails 4.0.0

Below are the steps to fix it:

STEP 1: Download MYSQL-C-Connector library (I downloaded mysql-connector-c-noinstall-6.0.2-win32 version)

STEP 2: Extract the file (without space) and put it on your drive (example C:\mysql-connector-c-6.0.2-win32).
Rename it to something that is easy to read (eg. “mysqlc32″) and then put the folder to your C drive.


STEP 3: Copy the libmysql.dll file on your MySQL server lib directory  “C:\Program Files\MySQL\MySQL Server 5.6\lib” and paste it on your ruby bin directory “C:\Ruby200\bin”

STEP 4: Figure outWrite down these directories:

  • Directory to windows system 32: c:\windows\system32;c:\windows;
  • Directory to your ruby bin: C:\Ruby200\bin;
  • Directory to your MysqlServer: C:\Program Files (x86)\MySQL\MySQL Server 5.6;
  • Directory to your mysql connector lib: C:\mysqlc32\lib;

    Combine these directories into one line: c:\windows\system32;c:\windows;C:\Ruby200\bin;C:\Program Files (x86)\MySQL\MySQL Server 5.6;C:\mysqlc32\lib

STEP 5: Go to your Control Panel\System and Security\System. Click Advanced System Setting > Environment Variable > Edit “Path”. Paste your directories into “Path” :


Click OK > OK to save it.

STEP 4: Run this command on your command line :

– C:\mysqlc32″ is the directory to your C connector (see STEP 2)


Now, you should be able to use mysql2 gem in your project.


No comments yet.

Leave a Reply