I've been experimenting with Ruby 1.9.1 and trying to make it my natural home recently. Crucial to that was getting the mysql gem installed. Actually it's fairly straightforward with the 2.8.1 version of the gem and only very minor mods to the official instructions at http://www.tmtm.org/en/mysql/ruby/ were required.

Note that I have only tried this to work against MySQL 5.0.x, which I have installed in /usr/local/mysql, as all my previous attempts to use MySQL 5.1 have failed miserably and I've given up on that for now. These instructions install from source, resulting in a fresh /usr/local/ruby191/lib/ruby/site_ruby/1.9.1/mysql.bundle. Then you can simply require 'mysql' in your Ruby code and you're away.

  • Downloaded 2.8.1 source tgz from RubyForge, linked from http://www.tmtm.org/en/mysql/ruby/ downloads section.
  • Expanded the tgz with Finder, then opened a command prompt…
  • > cd mysql-ruby-2.8.1
  • > ruby extconf.rb –with-mysql-config=/usr/local/mysql/bin/mysql_config -with-mysql-dir=/usr/local/mysql
  • > make
  • > sudo make install
Et voila! Note that make did output a bunch of warnings about implicit 64/32 bit conversion that suggests the code isn't entirely 64 bit happy, but I've not observed any problems as a result. Yet.

1 Comment

  1. Thanks for the info. Regarding MySQL 5.1, the 2.8.1 mysql gem works with it fine. Here’s the set up I’m using:
    $ mysql –version
    mysql Ver 14.14 Distrib 5.1.36, for apple-darwin9.7.0 (powerpc) using EditLine wrapper
    $ ruby –version
    ruby 1.9.1p243 (2009-07-16 revision 24175) [powerpc-darwin9.7.0]
    $ gem –version
    1.3.4
    Note that I’m not using the rubygems that came with ruby 1.9.1 (I installed rubygems as noted here before learning that ruby 1.9.1 included it).

Leave a Reply

Your email address will not be published. Required fields are marked *