Update: Some comments were mysteriously deleted, sorry if yours is not appearing, thanks for commenting though! One person responded that they needed to install the XCode tools first. I think they were building or upgrading ruby (which I didn’t do). There are certainly no issues with doing this step first, I just didn’t need to until I installed mysql.

I just recently finished tackling this oft attempted-failed-blogged-fixed(but not for you) ritual, getting a working ROR sandbox with mysql.
Many others have blogged about this, trust me I spent many days reading them, and the approaches and results are all over the map.
Sorry to say, this post is not the be-all end-all solution that other blogs claim. It’s just what I did, posted mainly for my own documentation.

First, my requirements. My web host, Site5, currently has installed Ruby 1.8.7 and Rails 2.2, plus MySQL 5.1.x. So I wanted my dev environment to be close to what my deployment environment will be.
I prefer to understand as much about my dev environment as I can, I want to know how things work, so that I can control them. So magic out-of-the-box solutions generally aren’t favored.
However, I’m generally the person that does it the hard way, and also runs into all those problems that people post about on the web, it never just works. And I’ve got a lot of grokking ahead of me as it is, so taking the easiest approach migh not be bad this time.

After researching this, I boiled down the options to 3 popular approaches:

Use the default mac installation of ruby, upgrade the rails gem and install mysql

Build an entirely new environment from scratch, as detailed in the oft-cited Hivelogic article.

Option 1 seemed to be the easiest, but Leopard comes with Ruby 1.8.6 installed, I will use 1.8.7 in production, probably not a deal breaker. Also there is a potential that a future OS update could break something in my existing sandbox.

Option 2 gives me the magic all-in-one solution, but I always worry that I’m putting myself in their box. Plus the community seems pretty split on macports in general.

Option 3 gives me total control, and the best chance for everything going to hell.

In the end I decided on option 1, use the existing mac install and upgrade rails. I figured I start there, the other 2 options are still open to me if I find its needed.

“Finally, just get to it”. Surprisingly, everything worked very well, here’s how I did it.

In order to upgrade to 2.x rails gem, the gems package manager must be updated.

Ok, time install mysql. First thing is to make sure Xcode tools are installed.

If you have your Leopard installation DVD, load it now. If you don’t have an installation DVD, you can download the Xcode 3.0 tools at Apple’s Developer Web Site. (Note: Apple developer accounts are free.)

Open the Optional Installs folder, and then the Xcode Tools folder. Double click on the XcodeTools.mpkg installer and select a standard install. This will take a few minutes to run.

Download MySQL from their site. Make sure to get the 32-bit mac version.
This a native mac application and is installed like any mac app.

Once mysql has been installed, the mysql gem must be installed.

There seem to be 2 secrets to make it work. First you point the gem to the mysql client config folder, instead of the mysql home. Second, if on an intel machine, provide the env ARCHTYPE flag.