MySQL not auto starting on Yosemite

MySQL not auto starting on Yosemite

I was setting up a Mac Mini to replace the existing sd3labs office Linux server and ran across an issue with MySQL not starting on reboot, hell it actually gave an error on install saying the installed failed which it really didn’t. I came across a post on Stackoverflow explaining how to correct this and thought I would mirror the info here.

The first thing you need to do is create the following file /Library/LaunchDaemons/com.mysql.mysql.plist

In the com.mysql.mysql.plist file that you just created you will need to then add the following information to it.

<!--?xml version="1.0" encoding="UTF-8"?-->
<plist version="1.0">
  <dict>
    <key>KeepAlive</key>
    <true />
    <key>Label</key>
    <string>com.mysql.mysqld</string>
    <key>ProgramArguments</key>
    <array>
      <string>/usr/local/mysql/bin/mysqld_safe</string>
      <string>--user=mysql</string>
    </array>        
  </dict>
</plist>

And lastly make sure to give it the proper permissions so it can be executed properly at startup, and then add it to launchctl as shown here.

sudo chown root:wheel /Library/LaunchDaemons/com.mysql.mysql.plist
sudo chmod 644 /Library/LaunchDaemons/com.mysql.mysql.plist
sudo launchctl load -w /Library/LaunchDaemons/com.mysql.mysql.plist

After all said and done you should be able to reboot the system and MySQL will be running when it comes back up.