Installing mysql gem on MAC OS + XAMPP + Rails 2.3

8
Nov
4

If you are on a MAC, using the easygoing XAMPP and need that rails app to get up and running using MySQL, then read on.

So Rails 2 does not come with the mysql gem installed.

You run:

gem install mysql

and to your shock you get:

ERROR:  Error installing mysql:
ERROR: Failed to build gem native extension.

And in your log you see:

no such file to load -- mysql

Before you do anything, make sure you download the “developer package” from XAMPP website.

Then in your terminal run this command:

sudo env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-dir=/Applications/XAMPP/xamppfiles/lib/mysql --with-mysql-lib=/Applications/XAMPP/xamppfiles/lib/mysql/ --with-mysql-include=/Applications/XAMPP/xamppfiles/include/mysql/

And finally, it worked!

Found this useful?

Why not subscribe to my RSS feed!

Filed under: Ruby on Rails

// 4 Comments

  1. netboy
    1:27 pm on September 11th, 2010

    Hi, great post!

    One more step to mention is you should make sure you have xcode installed before running “gem install mysql” command. It can be found on mac os dvd.

  2. Bachir El Khoury
    12:32 pm on September 12th, 2010

    Thanks for you comment netboy.

    Why do you need xcode to be installed to run “gem install mysql”?
    you could be right, i already had xcode installed, but just curious to know why is it required.

  3. Jonathan E.
    8:08 pm on December 27th, 2010

    Ah, excellent. Just what I needed. Many thanks.

  4. Dr.Kameleon
    1:31 pm on January 26th, 2011

    Oh, THANX buddy!

    I had been struggling with this error for so much time! :-)

Leave a comment

RSS feed for comments on this post