Being primarily a PHP developer I always have one AMP package installed in my machine no matter what platform I work with. Now-a-days as I work on my macbook I have MAMP installed.
Few days back I was trying to install mysql2 gem to use in Rails app which acts as the interface between MySql engine and Rails(or Ruby) apps. But it was constantly failing every time I tried to. I even tried to install previous versions of mysql2 gem but no luck. Then I tried to have a closer look at the error the bundle install command was spitting out into the terminal.
It was not being able to find mysql header files which are required to compile mysql2 gem. After searching in the internet I found out MAMP doesn’t ship mysql headers by default.
So The options I had was either recompile Mysql from source and add headers into proper MAMP Directory. Or manage another mysql installation only for rails which is a whole lot of pain. So I had to go for one, I searched through Stack Overflow and found some tutorials on how to do that. After studying some of those I finally took a backup of mamp and started the recompilation process. Here are the steps I followed:
Take a backup of your whole MAMP directory if by any chance you mess it up. :) It’s always safe.
- First you need to download the MAMP open source components from their source forge page here
http://sourceforge.net/projects/mamp/files/mamp/ download the components for mamp 2.0.2 that is the latest now.
- Recently MAMP have switched from MySql 5.1 to to MySQL 5.5. And MySQL, in turn, has switched from GNU Make (with ./configure) to CMake (with cmake .). So you need to have cmake installed in you Mac. You can do that easily using brew or macport using the following command
1 2 3 4 5
- Suppose You have downloaded it into your desktop then Extract and put the mysql-5.5.9.tar.gz file into your desktop and type in the following command in your terminal.
1 2 3 4 5 6 7 8 9 10
- after this you should see 1 Gem installed successfully message into the termnal and you gem has been install successfully. Now you need to symlink a bundle from your mysql Library into /user/lib. Run the following command in the terminal.
1 2 3
rm -rf /tmp/mysql-5.5.9 /tmp/mysql-5.5.9.tar.gz