34 lines
1.3 KiB
Markdown
34 lines
1.3 KiB
Markdown
|
---
|
||
|
title: "Install ruby-mysql on Mac OS X 10.4 Tiger"
|
||
|
kind: article
|
||
|
slug: install-ruby-mysql-on-mac-os-x-104-tiger
|
||
|
created_at: 2006-12-06
|
||
|
tags:
|
||
|
- General
|
||
|
- Everything
|
||
|
- RubyOnRails
|
||
|
- Features
|
||
|
- Mac OS X
|
||
|
---
|
||
|
|
||
|
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:
|
||
|
|
||
|
<pre lang="bash">$ sudo gem install mysql
|
||
|
...
|
||
|
ERROR: Failed to build gem native extension.</pre>
|
||
|
|
||
|
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!
|
||
|
<!--more-->
|
||
|
|
||
|
Just compile the gem yourself, and add some special ingredients. Well, not even that. Just compile it again like this:
|
||
|
|
||
|
<pre lang="bash">$ 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</pre>
|
||
|
|
||
|
Now, you have the ruby-mysql gem installed and ready to go! No more dropped MySQL connections for Rails!
|