Quit MySQL without it restarting on El Capitan

回眸只為那壹抹淺笑 提交于 2019-11-28 23:13:24

What finally worked for me was stopping MySQL through the Mac System Preferences interface. That killed mysql without it coming back.

Manjunath Krishnamurthy

On macOS Sierra, this worked for me

Stop MySQL:

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

Start MySQL:

launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
Theory

On OS X El Capitan, this worked for me:

sudo launchctl unload -F /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist
mlcork

I found that the following commands worked for me:

To Stop mysql:

sudo launchctl unload -F /Library/LaunchDaemons/com.mysql.mysql.plist

To Start mysql:

sudo launchctl load -F /Library/LaunchDaemons/com.mysql.mysql.plist

On my config I found this:

$ cat /Library/LaunchDaemons/com.mysql.mysql.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>KeepAlive</key>
    <true />
    <key>Label</key>
    <string>com.mysql.mysqld</string>
    <key>ProgramArguments</key>
    <array>
      <string>/usr/local/mysql/bin/mysqld_safe</string>
      <string>--user=mysql</string>
    </array>
  </dict>
</plist>

You need to: change that true tag after KeepAlive to false and unload the daemon as others have suggested. In my case that was: sudo launchctl unload -F /Library/LaunchDaemons/com.mysql.mysql.plist && launchctl load /Library/LaunchDaemons/com.mysql.mysql.plist

Once the daemon will have restarted with the new config it will not keep mysql from being shut down when you kill it from the preferences.

If you used homebrew to install mysql, mysqld will keep on restarting unless you use following brew command:

brew services list

Get the name of service to stop and then run the following command:

brew services stop mysql@5.5

As per Theory's answer, this is still effective for Mojave.

sudo launchctl unload -F /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist

Per amacrobert, if you are facing this issue of mysqld continuing starting up, this is most likely due to you having mysql installed on the system level and by default, it will startup automatically on a computer restart.

In my situation, I was confused after a computer restart why my docker mysql container complained about an already allocated port. After continual debugging, I remember I installed mysql on the system level and never restarted my computer!

Cheer.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!