There are a number of solutions for compiling mysql with MAMP on OS X but there’s a simpler solution.

  1. Download and install MySQL (any version, I did 5.5.14 which is the latest as of this writing). Choose the “Mac OS X ver. 10.6 (x86, 64-bit), DMG Archive” option.
  2. From Terminal, run the following in your rails app’s directory:

    sudo gem install mysql2 --version=0.2.6 -- --with-mysql-dir=/usr/local/mysql
    GEMDIR=`dirname \`bundle show rails\``
    sudo install_name_tool -change libmysqlclient.18.dylib /usr/local/mysql/lib/libmysqlclient.18.dylib ${GEMDIR}/mysql2-0.2.6/lib/mysql2/mysql2.bundle
  3. In your database.yml file point to MAMP’s mysql.sock file:

    socket: /Applications/MAMP/tmp/mysql/mysql.sock