If you are running ruby in Mac OS X Lion and are having trouble with MySQL with the ever annoying message "uninitialized constant MysqlCompat::MysqlRes please do not spend the hours I did trying to solve it. Here is how to do it. The instructions below assume you have a 64 bits processor.
- Make sure you have MySQL installed. You need to download it from http://dev.mysql.com/downloads/mysql/, choose any Mac OS X ver. for x86, 64-bit, DMG Archive for an Intel Mac. The easiest format is the .dmg file as it allows for an installation visually using the GUI and comes with a panel for the Preference Settings.
- Now be sure that there are no mysql gems installed by running the command
sudo gem uninstall mysql.
- This seems to be the most important step for Mac OS Lion, as everything else is commonly tipped in every page with solutions to the MysqlCompat::MysqlRes Error. What you need to do is add the command "
export DYLD_LIBRARY_PATH="/usr/local/mysql/lib:$DYLD_LIBRARY_PATH"" to your ~/.bash_profile. Reload your terminal screen or run source ~/.bash_profile.
- Next step is installing and compiling with native directives the mysql gem. Here is the command "
env ARCHFLAGS="-arch x86_64" sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql --with-mysql-config=/usr/local/mysql/bin/mysql_config".
That's it! Happy developing!