Installing the Ruby mysql-2.7 gem on OS X 10.4/ 10.5

Today I was updating a rails application, and editing some databases to convert them to mysql.

After changing my rails config file I started getting this error :

> db:test:prepare
(in /Users/tom/workspace/solitaire)
!!! The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql.
rake aborted!

Strange, everything was working correctly on the other mysql databases and projects on my system. Anyway, I did as instructed :

> sudo gem install mysql
Password:
Building native extensions.  This could take a while…
ERROR:  Error installing mysql:
ERROR: Failed to build gem native extension.

/opt/local/bin/ruby extconf.rb
checking for mysql_query() in -lmysqlclient… no
checking for main() in -lm… yes
checking for mysql_query() in -lmysqlclient… no
checking for main() in -lz… yes
checking for mysql_query() in -lmysqlclient… no
checking for main() in -lsocket… no
checking for mysql_query() in -lmysqlclient… no
checking for main() in -lnsl… no
checking for mysql_query() in -lmysqlclient… no

Gem files will remain installed in /opt/local/lib/ruby/gems/1.8/gems/mysql-2.7 for inspection.
Results logged to /opt/local/lib/ruby/gems/1.8/gems/mysql-2.7/gem_make.out

I did some searching and found a few older articles on the problem :

http://blog.wearesakuzaku.com/installing-the-mysql-ruby-gem-on-os-x/

I tried all of the suggested solutions on this page, and none of them seemed to make any difference, so I did some more searching, and I found that I had a 64bit version of mysql installed, and the rails gem didn’t seem to like this. So I downloaded and installed the latest 32bit version of mysql :

http://dev.mysql.com/get/Downloads/MySQL-5.0/mysql-5.0.81-osx10.5-x86.dmg/from/http://mirrors.dedipower.com/www.mysql.com/

and then ran:

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

That seemed to fix the problem.

This entry was posted in Ruby on Rails and tagged , , , , . Bookmark the permalink.

Leave a Reply

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

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>