DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

MySQL Launchd Item For Mac OS X Tiger

06.07.2005
| 5353 views |
  • submit to reddit
        (Originally posted at <a href="http://blog.unquiet.net/archives/2005/05/19/launchd-item-for-mysql/">Unquiet</a>)

I had to reinstall Mysql because it wasn’t one of the things I backed up before erasing my hard drive. Since I’m now running Mac OS X 10.4 “Tiger�, I decided to set it up to start when the system boots, but the system for creating startup items has changed slightly. So I saved the following xml in <strong>/Library/LaunchDaemons/com.mysql.Mysql.plist</strong>:

<?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC 
         "-//Apple Computer//DTD PLIST 1.0//EN" "
        http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
        <key>Label</key>
        <string>com.mysql.Mysql</string>
        <key>OnDemand</key>
        <false/>
        <key>ProgramArguments</key>
        <array>
                <string>/usr/local/mysql/bin/mysqld_safe</string>
        </array>
        <key>ServiceDescription</key>
        <string>Mysql 4.1 Database Server</string>
        <key>UserName</key>
        <string>mysql</string>
        <key>WorkingDirectory</key>
        <string>/usr/local/mysql</string>
    </dict>
    </plist>

Note that I'm using the official OSX distribution of MySQL... but with a few changes to match your database location, you can get this to work with other installs (fink, darwinports, etc).