I just had trouble installing and running Mysql on 5.1.39. Here's what worked:
brew install mysql
This printed some instructions which got mysql running just fine, but
mysql gem decided to be difficult - uninitialized constant
MysqlCompat::MysqlRes. Some googling found the solution:
export ARCHFLAGS="-arch i386 -arch x86_64" gem install mysql -- --with-mysql-dir=/usr/local \ --with-mysql-config=/usr/local/bin/mysql_config
That's assuming your homebrew prefix is
/usr/local. Worked for me!