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


当前回答

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

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.

其他回答

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

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

获取可用服务的列表

brew services list

sudo / opt /地方/ etc / LaunchDaemons / org.macports.mysql5 / mysql5。包装器停止

您还可以在这里使用start和restart。我通过查看/Library/LaunchDaemons/org.macports.mysql.plist的内容发现了这一点。

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

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

正如@gediminas所说

系统参数> MySQL >停止MySQL服务器

是最简单的方法。从Oracle下载二进制安装程序。

这适用于macOS 10.13.6和8.0.12 MySQL

/usr/local/mysql/support-files / mysql。服务器启动

/usr/local/mysql/support-files / mysql。服务器重启

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