Documentation Home
MySQL Installation Guide
Related Documentation Download this Excerpt

MySQL Installation Guide  /  Installing MySQL on OS X  /  Installing a MySQL Launch Daemon

6.3 Installing a MySQL Launch Daemon

OS X uses launch daemons to automatically start, stop, and manage processes and applications such as MySQL.


Before MySQL 5.6.26, the OS X builds installed startup items instead of launchd daemons. However, startup items do not function as of OS X 10.10 (Yosemite). The OS X builds now install launchd daemons.

By default, the installation package (DMG) on OS X installs a launchd file named /Library/LaunchDaemons/ that contains a plist definition similar to:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "">
<plist version="1.0">
    <key>Label</key>             <string></string>
    <key>ProcessType</key>       <string>Interactive</string>
    <key>Disabled</key>          <false/>
    <key>RunAtLoad</key>         <true/>
    <key>KeepAlive</key>         <true/>
    <key>SessionCreate</key>     <true/>
    <key>LaunchOnlyOnce</key>    <false/>
    <key>UserName</key>          <string>_mysql</string>
    <key>GroupName</key>         <string>_mysql</string>
    <key>ExitTimeOut</key>       <integer>600</integer>
    <key>Program</key>           <string>/usr/local/mysql/bin/mysqld</string>
    <key>WorkingDirectory</key>  <string>/usr/local/mysql</string>

Some users report that adding a plist DOCTYPE declaration causes the launchd operation to fail, despite it passing the lint check. We suspect it's a copy-n-paste error. The md5 checksum of a file containing the above snippet is 60d7963a0bb2994b69b8b9c123db09df.

To enable the launchd service, you can either:

  • Click Start MySQL Server from the MySQL preference pane.

    Figure 6.6 MySQL Preference Pane: Location

    Content is described in the surrounding text.

    Figure 6.7 MySQL Preference Pane: Usage

    Content is described in the surrounding text.

  • Or, manually load the launchd file.

    shell> cd /Library/LaunchDaemons
    shell> sudo launchctl load -F
  • To configure MySQL to automatically start at bootup, you can:

    shell> sudo launchctl load -w

When upgrading MySQL server, the launchd installation process will remove the old startup items that were installed with MySQL server 5.6.25 and below.

User Comments
User comments in this section are, as the name implies, provided by MySQL users. The MySQL documentation team is not responsible for, nor do they endorse, any of the information provided here.
  Posted by Jacob Nikom on April 15, 2015
Previously it was user who managed the MySQL server - start and stop it. In OSX user manages MySQL daemon who in turn manages MySQL server.

To disable MySQL service (stop the daemon) use the command
sudo launchctl unload -w /Library/LaunchDaemons/com.mysql.mysql.plist

This command stops MySQL server as well as daemon.

You can see MySQL server process using commands:
shell> sudo launchctl list|grep mysql
98201 0 com.mysql.mysqld

If you MySQL server is running, but you don't see it in the list, it means the installation probably was not correct
  Posted by Jacob Nikom on April 15, 2015
To tell MySQL daemon (service) to start and stop MySQL server use the following commands:
shell> sudo launchctl start com.mysql.mysqld
shell> sudo launchctl stop com.mysql.mysqld

Wait until the server stops - there is no indication on the command line that the server is stopping.

sudo is important, but they could be run under root user account without sudo
  Posted by Mark Stevens on July 10, 2015
I had to remove the DOCTYPE line from the plist file as I was getting the error "Invalid property list" when I tried the launchctl command.

Hope this helps.
  Posted by Glen McAllister on July 23, 2016
One thing to note about the default supplied launchd .plist file - any method of stopping mysql besides launchctl unload <file> will result in mysqld being immediately restarted, because of the non-conditional keep-alive. For more "traditional" mysql behaviour, I remove that key.