title: Can't get mysql2 gem to work with MAMP2 and RVM on Lion, Rails3 app
body: <p>I am using MAMP2, rvm on OS X Lion and there is no way I can get mysql2 gem to work with my Rails app.</p>
  
  <p>I've followed this blog post <a href="http://blog.mirotin.net/35/mamp-1-9-5-mysql-5-5-9-and-ruby-mysql2" rel="noreferrer">http://blog.mirotin.net/35/mamp-1-9-5-mysql-5-5-9-and-ruby-mysql2</a> and this one <a href="http://www.pa-ket.com/blog/show/12-osx-ruby-mysql2-gem-python-mysqldb-using-mamp" rel="noreferrer">http://www.pa-ket.com/blog/show/12-osx-ruby-mysql2-gem-python-mysqldb-using-mamp</a></p>
  
  <p>These were the steps:</p>
  
  <pre><code>$ cd /tmp
  $ mv /Users/yourname/Desktop/mysql-5.5.9.tar.gz .
  $ tar xf mysql-5.5.9.tar.gz
  $ cd mysql-5.5.9
  $ brew install cmake
  $ cmake . -DMYSQL_UNIX_ADDR=/Applications/MAMP/tmp/mysql/mysql.sock -DCMAKE_INSTALL_PREFIX=/Applications/MAMP/Library
  </code></pre>
  
  <p>This step failed:</p>
  
  <pre><code>$ make -j 3
  </code></pre>
  
  <p>After commenting unit tests for 'my_atomic-t.dir' in /tmp/mysql-5.5.9/CMakeFiles/Makefile2 'make -j 3' went ok.</p>
  
  <pre><code>$ cp libmysql/*.dylib /Applications/MAMP/Library/lib/
  $ mkdir -p /Applications/MAMP/Library/include/mysql
  $ cp include/* /Applications/MAMP/Library/include/mysql
  $ env ARCHFLAGS="-arch x86_64" gem install mysql2 -v 0.2.11 -- --with-mysql-config=/Applications/MAMP/Library/bin/mysql_config
  Building native extensions.  This could take a while...
  Successfully installed mysql2-0.2.11
  1 gem installed
  Installing ri documentation for mysql2-0.2.11...
  Enclosing class/module 'mMysql2' for class Client not known
  Installing RDoc documentation for mysql2-0.2.11...
  Enclosing class/module 'mMysql2' for class Client not known
  </code></pre>
  
  <p>I guess 'Client not known' warning was nothing critical.<br>
  And the final step:</p>
  
  <pre><code>install_name_tool -change /tmp/mysql-5.5.9/libmysql/libmysqlclient.16.dylib /Applications/MAMP/Library/lib/libmysqlclient.16.dylib ~/.rvm/gems/ruby-1.9.2-p290@global/gems/mysql2-0.2.11/ext/mysql2/mysql2.bundle
  </code></pre>
  
  <p>And the error I get when starting rails server:</p>
  
  <pre><code>$ rails server
  =&gt; Booting WEBrick
  =&gt; Rails 3.0.7 application starting in development on http://0.0.0.0:3000
  =&gt; Call with -d to detach
  =&gt; Ctrl-C to shutdown server
  [FATAL] failed to allocate memory
  </code></pre>
  
  <p>I just can't set that mysql2 gem and I've been trying for weeks. After numerous errors trying to install mysql2 gem, this is where I'm completely stuck.</p>
  
  <p>I am using RVM and ruby-1.9.2-p290 on OS X Lion with MAMP 2.0.3 and Rails 3.0.7.</p>
  
  <p>Any help is <strong><em>greatly</em></strong> appreciated!</p>