MySql, Ruby and Snow Leopard (yet another post)

The blogosphere is full of a lot of posts about this particular problem, but I thought I’d chime in with my own insights. This is evidenced by two errors. First, whenever you try to do any kind of rake db task:

rake aborted!
uninitialized constant MysqlCompat::MysqlRes

Second, you cannot install the Mysql Gem. missing libraries, or other errors, didn’t save them when I got them! Sorry.

Solution Part 1: Know Your Computer
I have an old MacBook2,1 with 64-bit core 2 duo processor. That means, it’s “x86_64” architecture. It is not “i386”. It took me a while to convince myself of this. I looked up under the Apple at the MacBook’s “about this Mac,” I read the Wiipedia site on the Mac series- FYI all kindsa nerdy details at the Model Specifications section.

Solution Part 2: Re-Install MySql & Gem
I finally got Ruby on Rails to register my MySql installed 64-bit software by doing the following:

  1. Check if there’s any running instances of MySQL
    > ps -ef | grep mysql
  2. Kill them if you find them:
    > sudo kill [insert pid]
  3. Delete the old MySql directories (if you have the Startup, go there and delete those. I didn’t.)
    >cd /usr/local
    >sudo rm mysql*
  4. Uninstall Ruby’s MySql gem.
    >sudo gem uninstall mysql
  5. I rebooted here. Not technically necessary, but it was advised somewhere, so I did it, and I think it’s a good idea.
  6. Download and install the MySql *for your architecture*.Mine is (x86_64)…
  7. Install the gem with associated flags:
    >sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-dir=/usr/local/mysql --with-mysql-lib=/usr/local/mysql/lib --with-mysql-include=/usr/local/mysql/include --with-mysql-config=/usr/local/mysql/include

    Note: remove the new line endings, it should all be on one line.

  8. Get the MySql server running –
    > cd /usr/local/mysql > sudo ./bin/mysqld_safe (Enter your password, if necessary) (Press Control-Z) > bg (Press Control-D or enter "exit" to exit the shell)
  9. To test, go back and run that rake task.


  • If you get an error about hash class detection, that’s an issue with 32-bit running on a 64-bit architecture. The 32-bit MySql and 32-bit ruby gem won’t basically work despite both being compatible with each other. This is in the library of gem data connection classes.
  • If you can’t compile the gem, that’s due to it not being able to find the classes in your MySQL installation- that’s why we’re sending it all of the paths in the command line gem build.
  • Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2) (Mysql::Error)

    that error is due to MySql server not running as a process on your Mac. So do that- instructions are above.

  • Did you like the gratuitous photo of my cat? Makes these tech posts more interesting!

    More Reading
    Ruby forum from 11/2009

    StackOverflow on the same issue
    More explanation re: archtypes on TechLiberty blog


  1. Comment by Charlie

    Posted on July 13, 2011 at 10:46 am

    Hi i got a 32-bit MySql and 32-bit ruby gem but it doesn't work. How can i resolve this one. Biltricide

  2. Comment by thongchai

    Posted on September 15, 2011 at 6:23 pm

    looking for xbox 306 controller xbox306

  3. Comment by sigit hermawan

    Posted on April 29, 2012 at 12:57 pm

    nice post…

  4. Comment by Marry Jones

    Posted on July 5, 2012 at 11:47 am


    I was very pleased to find this site.I wanted to thank you
    for this great blogI definitely enjoying every little bit of it and I have you
    bookmarked to check out new stuff you post.

    business plan

  5. Comment by Salma Seo

    Posted on October 4, 2012 at 5:16 am

    Lowest cost official contract mobile phone deals UK. Free gifts & offers on Nokia, Samsung, Sony Ericsson, Blackberry, HTC, LG, Apple & Motorola smart-phones range.


  6. Comment by jak volni

    Posted on November 26, 2012 at 9:48 am

    Best online shopping
    store for products like luxury bed linen, bedding at bedbathlinen com au. We have got the largest range of
    products with every product having superior quality of its own and discounted
    prices now browse the best bedding for you.

  7. Comment by Karun Worradee

    Posted on January 10, 2013 at 6:31 am

    Thanks for this information.

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>