Archive for toukokuu 2013

How to install mysql gem in Cygwin

Here’s instructions how to install a mysql gem in Cygwin environment for Ruby on Rails. I spent a lot of time figuring this out. Enjoy!

1. Install the mysql client development library (libmysqlclient-devel) with cygwin’s setup.exe. With setup.exe, you should also install the c compiler (gcc), makefile utility (make) and cmake. We need these tools in the following steps when we build the mysql connector from source code.

2. Download the mysql c connector source code from http://dev.mysql.com/downloads/connector/c/ and extract it to some dir.

tar -xvf mysql-connector-c-xx.tar.gz

3. Create and configure the make file with cmake

cd mysql-connector-c-xxx
mkdir build
cd build
cmake ..

4. Compile and install

make
make install

5. Install the mysql2 gem using with-mysql-config option

gem install mysql2 -- --with-mysql-config=/usr/local/mysql/bin/mysql_config

Note that you need to use ’–’ before –with-mysql-config parameter in order it to work. In the gem home page (https://github.com/brianmario/mysql2) this is not mentioned in the installation instructions!

Ruby 1.9.3
MySQL c connector 6.1
Ruby on Rails 3.2.13
Rubygems 1.8.23