ERROR! MySQL server PID file could not be found!
Starting and stopping the MySQL server via Preferences Pane/launchd and on the other hand via sudo /usr/local/mysql/support-files/mysql.server start/stop are not really compatible.

After choosing "Launchd Support" in the MySQL installer the launch daemon com.oracle.oss.mysql.mysqld will be created and the MySQL preferences pane uses the launchd mechanism to start and stop mysql. If you enable "Automatically Start MySQL Server on startup", mysqld is enabled automatically after starting your Mac.

The pid file's name created by the launch daemon is not compatible with the one created and expected by the mysql-server script.

The launch daemon's pid file name created while running is mysql.local.pid, the script expects a name based on your Mac's hostname, .local or computer name though.

So either use the MySQL pref pane/launchctl or the script to start and stop mysqld.



To some extent you can make both methods compatible by modifying the file com.oracle.oss.mysql.mysqld though:

After stopping mysql replace the array

&lt;array&gt;
    &lt;string&gt;/usr/local/mysql/bin/mysqld&lt;/string&gt;
    &lt;string&gt;--user=_mysql&lt;/string&gt;
    &lt;string&gt;--basedir=/usr/local/mysql&lt;/string&gt;
    &lt;string&gt;--datadir=/usr/local/mysql/data&lt;/string&gt;
    &lt;string&gt;--plugin-dir=/usr/local/mysql/lib/plugin&lt;/string&gt;
    &lt;string&gt;--log-error=/usr/local/mysql/data/mysql.local.err&lt;/string&gt;
    &lt;string&gt;--pid-file=/usr/local/mysql/data/mysql.local.pid&lt;/string&gt;
&lt;/array&gt;


by

&lt;array&gt;
    &lt;string&gt;/usr/local/mysql/bin/mysqld&lt;/string&gt;
    &lt;string&gt;--user=_mysql&lt;/string&gt;
    &lt;string&gt;--basedir=/usr/local/mysql&lt;/string&gt;
    &lt;string&gt;--datadir=/usr/local/mysql/data&lt;/string&gt;
    &lt;string&gt;--plugin-dir=/usr/local/mysql/lib/plugin&lt;/string&gt;
    &lt;string&gt;--log-error=/usr/local/mysql/data/$name.err&lt;/string&gt;
    &lt;string&gt;--pid-file=/usr/local/mysql/data/$name.pid&lt;/string&gt;
&lt;/array&gt;


with $name: either HostName (e.g. host.example.com), LocalHostName (e.g. host.local) or ComputerName (e.g. host). Probably the best is to use a hostname. You may get a hostname with hostname with scutil --get HostName or set it with sudo scutil --set HostName your_hostname. 

You can also get the actually used mysql-server script pid's name - after stopping the launch daemon and starting mysqld with mysql-server start-  by checking mysql's data directory with sudo ls /usr/local/mysql/data. Use the name found there to adjust the plist's pid name.

You may have to convert the launch daemon file to xml to edit it. The app TextWrangler opens it as xml file immediately.

Reload the plist with launchctl afterwards.



Now should be able to start and stop with the MySQL pref pane and the mysql.server script.

If you have enabled "Automatically Start MySQL Server on Startup", you can't stop the server – even after modifying the plist – with the script because launchd overrides any stop command after a few seconds and launches mysqld again.