Installing MySQL/Ruby/Rails on Mac Lion with Homebrew

I’m following the excellent and descriptive ThinkVitamin Guide to installing Ruby, Rails, and MySQL, and while it’s only a couple months old, there are already a few discrepancies in my install compared to the one shown.

The first problem I ran into was in the “Install MySQL” section. I ran

brew install mysql

and all seemed well, but the next bits of code listed did not point to the right places, and I just kept getting “no such file or directory.” This is the tutorial code:

mysql_install_db --verbose --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
mkdir -p ~/Library/LaunchAgents
cp /usr/local/Cellar/mysql/5.5.15/com.mysql.mysqld.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/com.mysql.mysqld.plist

The problem is that my version of mysql is 5.5.19, so I had to edit that line, and the com.mysql.mysqld.plist was not there. I did find homebrew.mxcl.mysql.plist, and replacing the file name seems to have done the trick. Here’s the full code I used:

The first two lines are verbatim from the tutorial:

mysql_install_db --verbose --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
mkdir -p ~/Library/LaunchAgents

The next line has been modified for version 5.5.19, and it points to homebrew.mxcl.mysql.plist instead of com.mysql.mysqld.plist:

cp /usr/local/Cellar/mysql/5.5.19/homebrew.mxcl.mysql.plist ~/Library/LaunchAgents/

And the last line again points to homebrew.mxcl.mysql.plist:

launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist

After that, the all-important mysql -uroot command was a success!

As noted in the first comment on the ThinkVitamin post, I also ran into an issue with the tutorial’s rvm install, but this line worked:

rvm install 1.9.3 --with-gcc=clang

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>