It should have been a simple excercise. I just wanted to set up a dev environment for a Ruby on Rails app that uses MySQL on my Snow Leopard Macbook 5.5 – easy, right? I wish… after much trial-and-error, and many encounters with the dreaded error message:
"uninitialized constant MysqlCompat::MysqlRes"
… I finally got everything to work using the following steps:
- Installing the 64-bit version of MySQL 5.5.14 using the .dmg installer.
- removing all possibly pre-existing versions of the mysql gem:
sudo gem uninstall mysql
- Installing the correct gem with the following line:
sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
- This trick is missing from most howto’s: I needed to set the linker path.
After this, you can verify your installation is working with irb:
Motoko:project-rails karsten$ irb >> require 'rubygems' => false >> require 'mysql_api' => true >> Mysql.get_client_info => "5.5.14"
Having done this, the rake db creation and migration tasks went smoothly.