MySQL startup script on Mac OS X Snow Leopard

I’ve had problems starting up MySQL database server on startup on Snow Leopard.  MySQL preference pane seems to be flaky and it often fails to start MySQL server.

I created this startup script myself and it seems to work nicely.

sudo nano /System/Library/LaunchDaemons/org.mysql.mysqld.plist
<?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>RunAtLoad</key>
		<true/>
		<key>Umask</key>
		<integer>7</integer>
		<key>UserName</key>
		<string>_mysql</string>
		<key>Disabled</key>
		<false/>
		<key>WorkingDirectory</key>
		<string>/usr/local/mysql</string>
		<key>GroupName</key>
		<string>_mysql</string>
		<key>KeepAlive</key>
		<true/>
		<key>Program</key>
		<string>/usr/local/mysql/bin/mysqld</string>
		<key>Label</key>
		<string>org.mysql.mysqld</string>
		<key>ProgramArguments</key>
		<array>
			<string>--user=_mysql</string>
		</array>
	</dict>
</plist>

Now make sure file permission is correct and load the daemon.

sudo chown root:wheel /System/Library/LaunchDaemons/org.mysql.mysqld.plist
sudo launchctl load /System/Library/LaunchDaemons/org.mysql.mysqld.plist
sudo launchctl start org.mysql.mysqld

Restart your Mac and your MySQL server should be running.

Marko

  • Arnau

    I have been starting the server with the pref-pane for months as the checkbox of startup at boot didn’t work. Other solutions on the Web didn’t work but yours did, straight away.

    Thank you, man =)

    • You’re welcome. Glad it worked for you too 🙂

  • Bart

    Love ya! Thnx 🙂

  • Group hug 🙂