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

News

Testing my forthcoming app with the Rails 3 release candidate using the new mysql2-adapter. Seems blazingly fast.

On 30th of July 2010 via web

Rails 3.0.0.rc feels a lot more snappier than beta4 (at least in dev-environment).

On 27th of July 2010 via Twitter for iPhone

@thomasfuchs Maybe try blizznet if it's available — don't know if it's reliable, but it IS fast...

On 7th of July 2010 (in reply to thomasfuchs’s tweet) via Twitter for iPhone

Business logic is now rock-solid. Trying to boost performance now while hoping to release the thang in late summer.

On 7th of July 2010 via Twitter for iPhone

Hard when you realize that your whole application logic needs a complete refactoring before launch. Some design-decisions bite late.

On 1st of July 2010 via web


Please enable JavaScript if you want to comment!