Installing MySQL on OS X Mountain Lion

This post was published in 2012 and is kept here for reference. It may contain information that's outdated or inaccurate. All external links and references have been updated to point to archived versions on archive.org where possible.

I was having some issues getting MySQL installed on OS X 10.8 Mountain Lion, and then I came across a useful article describing how to do it.

Here’s the important information from the article to install MySQL on OS X 10.8 Mountain Lion using Homebrew:

Install Homebrew

$ ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"

Install MySQL using Homebrew

$ brew install mysql

Add MySQL to your LaunchAgents, so it can launch on startup

$ mkdir -p ~/Library/LaunchAgents
$ cp /usr/local/Cellar/mysql/5.5.27/homebrew.mxcl.mysql.plist ~/Library/LaunchAgents/
$ launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist

Unset TMPDIR (as this isn’t set to /tmp for non-root users) and install the MySQL system tables

$ unset TMPDIR
$ mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp

Set the root password for MySQL

$ /usr/local/Cellar/mysql/5.5.27/bin/mysqladmin -u root password 'YOUR_NEW_PASSWORD'

And lastly, start MySQL

$ mysql.server start

This post is also available in plain text

[Comments]

Want to comment? You can do so via Github.
Comments via Github are currently closed.

[Webmentions]

Want to reply? I've hooked up Webmentions, so give it a go!