Fixing MySQL autostart failure on Yosemite

There's been some DB errors on the website today because there had been reboots and MySQL failed to automatically start each time ever since upgrading to OS X 10.10 Yosemite. I knew of this problem, but since the disruption was starting to get annoying I decided to find a way to fix it. Apparently, the fix goes all the way to 2010 for fixing the same issue in OS X 10.6 Snow Leopard by Marko Tomic. Then a simpler version for Yosemite came up a few weeks ago, which is largely similar to a 2013 entry at Apple Support Communities.

This was happening because MySQL has been using a very old way to autostart the service and never bothered to update it, making it susceptible to failure for several years already. Until there's an official fix, the following should be entered into the Terminal.app, which is essentially creating a plist file for the LaunchDaemon to use on boot.

sudo nano /Library/LaunchDaemons/com.mysql.mysql.plist

Upon entering the "nano" editor, type (or paste) the following lines.

<!--?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>

Press Ctrl-O, Enter, then Ctrl-X to save and quit. Then you need to set the file's owner & permissions and load into the LaunchDaemon.

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

Finally, restart the Mac and MySQL should autostart. Remember to restart immediately.
Defined tags for this entry: , ,

Today's "The Toon-Box"

Defined tags for this entry: , ,

Copyright (C) 1996-2024 Woo-Duk Chung (Wesley Woo-Duk Hwang-Chung). All rights reserved.