MacOS – The server quit without updating PID file (/usr/local/var/thesql/NAME.pid)

homebrewmacosMySQL

I have installed mysql via brew. First start works, but after reboot, I got the following error:

The server quit without updating PID file (/usr/local/var/mysql/NAME.pid)

I start mysql with

sudo mysql.server restart

If I try to create a pid file on my own via terminal it will created, but after a few seconds it disappear.

sudo touch /usr/local/var/mysql/NAME.pid

Have anyone a idea?

Best Answer

YES.

Following homebrew caveats, did you setup launchd?

To have launchd start mysql at login:
    ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents
Then to load mysql now:
    launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist

Well, now using mysql.server is pointless. It basically doesn't work, because (from my poor understanding) mysqld is now managed by launchd, and it is mysqld_safe. I don't know if actually because of that is different from what you control with mysql.server.

The solution I came up with is to not use launchd for mysql from brew. Rather, I just use the mysql.server tool to start, stop, and restart mysql.

If you want to follow my steps, this is what you need to do:

launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist

And whenever you want to start the mysql server, use mysql.server start.

If you actually want to make mysql start at boot time, you can take that plist and copy it, delete the KeepAlice line, replace the string values under ProgramArguments with /usr/local/bin/mysql.server and start. After that do
launchctl load ~/path/to/com.file.plist