Search this blog:

Words and works.

Trouble with MySQL Gem

Ran into trouble installing the native MySQL database extension for Ruby via the gem command.

sudo gem install mysql

results in some complaints:

Building native extensions. This could take a while...
ERROR: While executing gem ... (RuntimeError)
ERROR: Failed to build gem native extension.

Apparently, on my Mac OS X Panther system, MySQL was installed in /usr/local/lib rather than /usr/lib.

To fix:

cd /usr/local/lib/ruby/gems/1.8/gems/mysql-2.6
sudo ruby extconf.rb --with-mysql-dir=/usr/local/mysql
sudo gem install mysql

More info here: http://wiki.rubyonrails.com/rails/show/MySQL+Database+access+problem

For Windows, here: http://www.bantamtech.com/~kevin/?p=28

Update:

Much simpler solution per Ruby on Rails mailing list:

sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql

Update 2:

An even simpler solution per Ruby on Rails mailing list:

sudo gem install mysql -- --with-mysql-config

Tags: mysql, rails | Permalink

© 2010 Evenhouse Consulting, Inc.

A Django site.