我通过MacPorts安装MySQL。我需要什么命令来停止服务器(我需要测试当MySQL死时我的应用程序如何行为)?


当前回答

在我的mac osx yosemite 10.10。这个命令起作用了:

sudo launchctl load -w /Library/LaunchDaemons/com.mysql.mysql.plist
sudo launchctl unload -w /Library/LaunchDaemons/com.mysql.mysql.plist

你可以在/Library/LaunchDaemons/文件夹中找到你的mysql文件来运行

其他回答

对我来说,它与mysql5一起工作

sudo launchctl unload -w /Library/LaunchDaemons/org.macports.mysql5.plist
sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql5.plist

Try

sudo <path to mysql>/support-files/mysql.server start
sudo <path to mysql>/support-files/mysql.server stop

其他的尝试:

sudo /Library/StartupItems/MySQLCOM/MySQLCOM start
sudo /Library/StartupItems/MySQLCOM/MySQLCOM stop<br>
sudo /Library/StartupItems/MySQLCOM/MySQLCOM restart

然而,我发现第二个选项只有在.plist已经加载了以下内容时才能工作(OS X 10.6, MySQL 5.1.50):

sudo launchctl load -w /Library/LaunchDaemons/com.mysql.mysqld.plist

PS:我还发现我需要卸载.plist来获得一个不相关的MAMP-MySQL安装,以正确启动/停止。运行之后,MAMP-MySQL启动正常:

sudo launchctl unload -w /Library/LaunchDaemons/com.mysql.mysqld.plist

如果你安装了MacPorts的MySQL 5包:

sudo launchctl  unload -w /Library/LaunchDaemons/org.macports.mysql.plist 

Or

sudo launchctl  unload -w /Library/LaunchDaemons/org.macports.mysql5-devel.plist 

如果您安装了mysql5-devel包。

如果你正在使用自制啤酒,你可以使用

brew services restart mysql
brew services start mysql
brew services stop mysql

获取可用服务的列表

brew services list

尝试了所有的命令行,还是不行。我要做的事情有:

mv /usr/local/Cellar/mysql/5.7.16/bin/mysqld /usr/local/Cellar/mysql/5.7.16/bin/mysqld.bak
mysql.server stop

这种方法有效,mysqld进程消失了。但是/var/log/system.log有很多垃圾:

Jul  9 14:10:54 xxx com.apple.xpc.launchd[1] (homebrew.mxcl.mysql[78049]): Service exited with abnormal code: 1
Jul  9 14:10:54 xxx com.apple.xpc.launchd[1] (homebrew.mxcl.mysql): Service only ran for 0 seconds. Pushing respawn out by 10 seconds.