Hi Folks,
In this short tutorial of mine, I am going to write down the steps of how you can install mysql2 gem with Ruby2.0 on Windows machine.
Installing Mysql gem is always a big time pain for most of the developers who are working on Windows machine. But thanks to active folks over the internet for their comments, posts.
Prerequisites:
1. Ruby 2.0.0 pre-installed.
2. DevKit installed
3. gem install rails – command should install all the gems. Return should be success.
Steps to install mysql gem:
1. Go to: http://dev.mysql.com/get/Downloads/Connector-C/mysql-connector-c-noinstall-6.0.2-win32.zip/from/pick, download will start automatically (don’t think at this moment that you’ve a 32 bit or 64 bit operating system.
2. Extract the folder to some place (in my case I am extracting it to C:\mysql-connector-c-noinstall-6.0.2
3. Run this command:
gem install mysql2 –platform=ruby — '–with-mysql-include=C:\mysql-connector-c-noinstall-6.0.2\include –with-mysql-lib=C:\mysql-connector-c-noinstall-6.0.2\lib –with-mysql-dir=C:\mysql-connector-c-noinstall-6.0.2' |
4. Output will return in below manner:
Temporarily enhancing PATH to include DevKit… | |
Building native extensions with: '–with-mysql-include=C:\mysql-connector-c-noinstall-6.0.2\include –with-mysql-lib=C:\mysql-connector-c-noinstall-6.0.2\lib — | |
with-mysql-dir=C:\mysql-connector-c-noinstall-6.0.2' | |
This could take a while… | |
Successfully installed mysql2-0.3.13 | |
Parsing documentation for mysql2-0.3.13 | |
unable to convert "\x90" from ASCII-8BIT to UTF-8 for lib/mysql2/mysql2.so, skipping | |
Installing ri documentation for mysql2-0.3.13 | |
1 gem installed |
5. If you see this message, create a new Rails4 application, open your Gemfile and use:
gem 'mysql2', '0.3.13'
and run bundle install. Once bundle install runs successfully. You should try:
rake db:create and
rake db:migrate
to ensure that gem is installed correctly.
Hope this will help someone!
Happy Coding!! 🙂