Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
MySQL on OS X using Homebrew

Change Permissions

You'll need to change the permissions for /usr/local for your local user.

sudo chown -Rwhoami/usr/local


The easiest way to get everything setup is to use Homebrew. To do this, you'll need to first install XCode from the standard XCode from Apple Developer site. Afterwards you can just install Homebrew though its normal installation

ruby -e "$(curl -fsSLk"

#Xcode You'll need to install Xcode. The simplest and easiest way is though the Apple App Store on OSX. It will cost $5 and will be able to be installed with 1 click. It will probably take a while (~ an hour) so you'll want to go and get some coffee... on the other side of town.

#MySQL When using OSX, preferred mysql build is 5.1.54 x86_64 because 5.5 is broken. THIS IS REALLY IMPORTANT!

The easiest way to get mysql 5.1 up and running is by grabbing a legacy homebrew formula by doing the following:

echo 'export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH" # Add MySql config' >> ~/.bash_profile

Close ALL open terminal windows. Open a new terminal.

brew install


#Setup MySQL as a LaunchDaemon Copy the plist file from where MySQL is installed to the /Library/LaunchDaemons directory. If you installed a different version of MySQL then the number below may be different. Don't panic.

sudo cp /usr/local/Cellar/mysql51/5.1.56/com.mysql.mysqld.plist /Library/LaunchDaemons/

#Launch MySQL Because you copied the plist file into the /Library/LaunchDaemons directory, MySQL will be automatically started on restart. The system will load any plist files in that directory. As a sanity (and time saving measure) try manually loading and unloading the file to make sure that everything went well.

launchctl load -w /Library/LaunchDaemons/com.mysql.mysqld.plist

mysql -u root

If you see a MySQL prompt then you're in business. If not, then something isn't functioning 100%.

Exit out of MySQL and then unload the module. It may take a minute or so to unload.

launchctl unload -w /Library/LaunchDaemons/com.mysql.mysqld.plist

mysql -u root

If you get a connection error, then everything is functioning properly.

Now launch the module again and you're ready to get to work with MySQL.

launchctl load -w /Library/LaunchDaemons/com.mysql.mysqld.plist


This comment has been minimized.

Show comment Hide comment

Amokrane Aug 4, 2015

Is mysql-5.6.25 broken too?

Amokrane commented Aug 4, 2015

Is mysql-5.6.25 broken too?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment