Using MAMP’s MySQL for Rails development
This article is merely a clone of Michael Boone’s blog post. These instructions worked like a charm the last time I needed them. Nonetheless, I’ll give this article a write-up the next time I flush my development machine.
The problem
You have installed MAMP and want to use its MySQL-functionalities for local development of your Rails application. What you do not want is installing another MySQL-instance only because the mysql gem does not talk to your MAMP-installation.
A solution
If you haven’t done it already, set up MAMP or MAMP Pro (I use version 1.9 as time of this writing) and rubygems — as you are probably using RVM on your development machine, make sure you’ve switched to the right environment before proceeding.
You will also need to have the Apple Developer tools installed.
Now, get on with it:
First, check out MAMP’s sourcecode from here (make sure you pick the right tag). Then untar the mysql-file and enter the directory:
$ tar xzvf mysql-5.0.41.tar.gz
$ cd mysql-5.0.41
Compile the libraries for the gem to link against:
$ ./configure --with-unix-socket-path=/Applications/MAMP/tmp/mysql/mysql.sock \
--without-server --prefix=/Applications/MAMP/Library
$ make -j2
Copy the compiled libraries into your MAMP folder:
$ cp libmysql/.libs/*.dylib /Applications/MAMP/Library/lib/mysql
Copy the MySQL-headers into your MAMP folder:
$ mkdir /Applications/MAMP/Library/include
$ cp -R include /Applications/MAMP/Library/include/mysql
Install the mysql gem:
$ env ARCHFLAGS="-arch i386" gem install mysql -- \
--with-mysql-config=/Applications/MAMP/Library/bin/mysql_config
Please enable JavaScript if you want to comment!