Wednesday, February 09, 2011

Ruby, Rails and MySQL 5.5 Oh my!

I've seen many postings regarding issues with running 64bit Ruby, Rails and MySQL 5.5 in Leopard/Snow Leopard, especially regarding the missing const error "MysqlCompat::MysqlRes" and the mysql.bundle library issues. After investing about an hour, I had an upgraded MySQL 5.5 and MySQL gem 2.8.1 installation, and I did it like this ...


  1. Download and install MySQL 5.5 (I untar it in /usr/local and create a "msyql" symlink to ease upgrades) - configure your /etc/my.cnf as necessary.

  2. Fire up your new MySQL installation to make sure it works (/usr/local/mysql/bin/mysqld_safe ...) will work for now, or you can go ahead and enable startup via launchctl.

  3. Uninstall all mysql gems (root and individual user level gems).

  4. Install the new gem for root:

    1. sudo su - (if you're not already root)

    2. env ARCHFLAGS="-arch x86_64" gem install --no-rdoc --no-ri mysql -- --with-mysql-dir=/usr/local/mysql --with-mysql-config=/usr/local/mysql/bin/mysql_config

    3. install_name_tool -change libmysqlclient.16.dylib /usr/local/mysql/lib/libmysqlclient.16.dylib /Library/Ruby/Gems/1.8/gems/mysql-2.8.1/lib/mysql_api.bundle

    4. vi (or mate) /Library/Ruby/Gems/1.8/gems/mysql-2.8.1/test/test_mysql.rb - add a require "rubygems"

    5. ruby test_mysql.rb - see if everything passes:
      (115 tests, 391 assertions, 0 failures, 0 errors)



  5. For user installed gem, do the same as you did for the root user, except update your paths accordingly.



--Noel (ngeren)

0 Comments:

Post a Comment

<< Home