HowTo: “gem install mysql” on OS X together with MAMP (Mac-Apache-MySQL-PHP)

mashpie » 24 August 2009 » In howto »

railsYou have a running MAMP Workflow on Mac. You are familiar with using Apache, MySQL etc. together. You now just want to try some more… Let’s say Ruby-on-Rails, ok RoR with MySQL and especially with MySQL provided by MAMP. As gem needs header and library of your MySQL-Server things might feel some kind of “boring old compiling stuff” – but it’s easy:

Well after trying some tipps and howtos I finally found the right resource out there http://boonedocks.net/mike/archives/175-MAMP-and-the-Ruby-MySQL-Gem.html Thanks a lot Mike!

You’ll need to have MAMP (or even MAMPPro) already installed. The main thing is to provide header and lib of the installed MySQL to gem for building the mysql extension, so step-by-step:

Download the MAMP-Sources (eg. from http://sourceforge.net/projects/mamp/files/). After download the .zip-file should be extracted to your Downloads-Folder, so fire up your Terminal.app and go to….

$ cd ~/Downloads/MAMP_1.7.2_src

now unpack the mysql-sources and change to the mysql directory:

$ tar xvfz mysql-5.0.41.tar.gz
$ cd mysql-5.0.41/

here you configure and compile the libs:

$ ./configure --with-unix-socket-path=/Applications/MAMP/tmp/mysql/mysql.sock --without-server --prefix=/Applications/MAMP/Library 
$ make -j2

after finished compiling copy the libs to your MAMP directory:

$ cp libmysql/.libs/*.dylib /Applications/MAMP/Library/lib/mysql

and now continue with the header files:

$ mkdir /Applications/MAMP/Library/include
$ cp -R include /Applications/MAMP/Library/include/mysql

as the last step you’ll install the mysql extension by gem like this:

$ sudo env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-config=/Applications/MAMP/Library/bin/mysql_config

that’s it! Good luck!

Share and Enjoy:
  • Print
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • LinkedIn
  • MisterWong
  • MySpace
  • RSS
  • Slashdot
  • Technorati
  • Twitter

Tags: , ,

Trackback URL

2 Comments on "HowTo: “gem install mysql” on OS X together with MAMP (Mac-Apache-MySQL-PHP)"

  1. mashpie
    Nathan Bertram
    19/11/2010 at 20:10 Permalink

    Awesome! Thanks :)

  2. mashpie
    Hargitai Dávid
    10/02/2011 at 08:54 Permalink

    Thank you very much! Works like a charm. :)

Hi Stranger, leave a comment:

ALLOWED XHTML TAGS:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

Subscribe to Comments