Skip to main content

Install ruby-mysql on Mac OS X 10.4 Tiger

·168 words·1 min· ·
General Everything RubyOnRails Features Mac OS X
Ariejan de Vroom
Author
Ariejan de Vroom
Jack of all Trades, Professional Software Craftsman

You probably know that the built-in mysql code in Rails sucks. To rephrase that, the ruby-mysql gem contains better code, so you want that. Rails automatically detects if you have ruby-mysql installed or not, and uses it if you have it.

Most notably, you want to install this gem if you get dropped MySQL connections running your Rails application.

So we do:

$ sudo gem install mysql
...
ERROR: Failed to build gem native extension.

Normall this would install fine, but not on Mac OS X. This is because Mac OS X keeps its code, headers and libraries in odd places (compared to Linux). But don’t panic. There’s an easy solution to all this!

Just compile the gem yourself, and add some special ingredients. Well, not even that. Just compile it again like this:

$ cd /usr/local/lib/ruby/gems/1.8/gems/mysql-2.7
$ sudo ruby extconf.rb --with-mysql-lib=/usr/local/mysql/lib --with-mysql-include=/usr/local/mysql/include
$ sudo make
$ sudo make install

Now, you have the ruby-mysql gem installed and ready to go! No more dropped MySQL connections for Rails!

Related

Installing Rails on Ubuntu Dapper / Edgy
·412 words·2 mins
General Everything RubyOnRails Features
Migrate SQLite3 to MySQL easily
·275 words·2 mins
General Everything RubyOnRails Databases Features
Tagging in ajax_scaffold
·468 words·3 mins
General Everything Web Development RubyOnRails Features