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


当前回答

在OSX雪豹

launchctl unload /System/Library/LaunchDaemons/org.mysql.mysqld.plist

其他回答

好吧,如果所有这些都失败了,您可以采取无情的方法,手动杀死运行MySQL的进程。

也就是说,

ps -Af

列出所有进程,然后执行“kill <pid>”,其中<pid>是MySQL守护进程(mysqld)的进程id。

sudo /usr/local/mysql/support-files / mysql。服务器停止

Use:

sudo mysqladmin shutdown --user=*user* --password=*password*

不使用sudo也能逃脱惩罚。例如,用户可以是root(即MySQL root用户)。

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

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.

你可以使用命令"mysqladmin shutdown"