Autostart MySQL Server on start-up – Mac OS X 10.10 Yosemite

After installing Yosemite, MySQL Server will no longer autostart on start-up.  If you are facing this problem of manually starting up MySQL Server every time you restart Mac OS X Yosemite, here is the solution.

Autostart MySQL Server on startup – Mac OS X Yosemite

USING TERMINAL & VIM:
1. Open Terminal
2. Create a new file “com.mysql.mysql.plist” at /Library/LauchDaemons/
cd /Library/LauchDaemons/
sudo vi com.mysql.mysql.plist
3. Copy and paste the following contents in the file. Using “vi” you need to press “i” to starting inserting and CMD+v to paste the contents.

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

4. Save the file. Using “vi” you need to press “esc” and then type “:wq” & press “enter” to save the file.
5. Change the permissions of the file using the following commands.
sudo chown root /Library/LaunchDaemons/com.mysql.mysql.plist
sudo chgrp wheel /Library/LaunchDaemons/com.mysql.mysql.plist
sudo chmod 644 /Library/LaunchDaemons/com.mysql.mysql.plist

6. Run the Launch script using the following commands
sudo launchctl load -w /Library/LaunchDaemons/com.mysql.mysql.plist

USING TEXTEDIT:
1. Open textedit app.
2. Click “New Document” on the left bottom or type Cmd + n
3. Enter the following contents

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

4. File -> Save… as “com.mysql.mysql.plist” on desktop.
5. Open “Macintosh HD” folder and select Library -> LaunchDaemons folders
6. Drag the “com.mysql.mysql.plist” to this LauchDaemons folder.
7. Authenticate to move it.
8. Open Terminal and type the copy and paste the following commands
sudo chown root /Library/LaunchDaemons/com.mysql.mysql.plist
sudo chgrp 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

Restart Yosemite to see your MySQL server auto-start on restart. You can check MySQL status in System Preferences if you have installed MySQLStartItem.pkg and MySQL.prefPane from the MySQL dmg. Read more about it at http://dev.mysql.com/doc/refman/5.1/en/macosx-installation-startupitem.html

Enjoy! and let me know in the comments if you have any problem.