This hits me every time when I try to install mysql gem on a new OS X machine. Here’s the trick and this should work for Snow Leopard too.

Prerequisite

  • Install Xcode 4.x Lion offers free Xcode 4 in Mac App Store.

  • Download and install “x86 64-bit” Mysql DMG (link) Install all supplied packages, it contains the necessary source code to build mysql gems

Install

Add Environment Variable

Testing

To make sure mysql or mysql2 gem works, simply create a new rails app by rails new myapp. And the config/database.yml should use mysql or mysql2 adapter. In addition in Rails 3, gem should be specified in Gemfile at root of the application folder by adding gem 'mysql' or gem 'mysql2' if mysql2 is used.

Leave a comment