Monthly Archives: July 2015

Setting MySQL to Load on Startup (Mac OS X 10.10)

It used to be that you could easily set up MySQL to load at startup using a MySQL plugin on system preferences. Unfortunately, Apple killed support for this in recent versions of OS X. So, you must set this up using a more Unix-like setting with launch daemon (launchd).

Here are the instructions for setting that up.

First, create a plist file at the following location. I’m using the vi editor because it’s easy.

sudo vi /Library/LaunchDaemons/com.mysql.mysqld.plist

Then fill it with the following XML.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Disabled</key>
    <false/>
    <key>GroupName</key>
    <string>_mysql</string>
    <key>KeepAlive</key>
    <true/>
    <key>Label</key>
    <string>com.mysql.mysqld</string>
    <key>Program</key>
    <string>/usr/local/mysql/bin/mysqld</string>
    <key>ProgramArguments</key>
    <array>
        <string>--user=_mysql</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>Umask</key>
    <integer>7</integer>
    <key>UserName</key>
    <string>_mysql</string>
    <key>WorkingDirectory</key>
    <string>INSTALL_PATH/mysql</string>
</dict>
</plist>

Then an adjust the permission:

sudo chown root /Library/LaunchDaemons/com.mysql.mysqld.plist
sudo chgrp wheel /Library/LaunchDaemons/com.mysql.mysqld.plist
sudo chmod 644 /Library/LaunchDaemons/com.mysql.mysqld.plist