MySql for Rails on OSX Leopard

May 06, 2008

As of now, this is much simpler than many blog posts make out.

I downloaded the OSX .dmg from http://dev.mysql.com/downloads/mysql/5.0.html#macosx-dmg, double clicked on the .dmg and installed

  1. mysql package
  2. mysql startup
  3. mysql preference pane

Then

  1. went to “system preferences” and started the server using the preference pane.
  2. ensured my path included “/usr/local/mysql/bin”
  3. checked local installation by running “mysql -u root” from a terminal

Installing the MySql Gem

This has following pre-requisites

  1. Installation of XCode
  2. Installation of MySql and ability to find mysql_config

I ran the following command

sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config

and the Gem installed fine

Finally tested by creating sample application

rails mysql-test -d mysql

Then in newly created folder

rake db:create:all

Then check databases exist in MySQL using “show databases;”.