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


当前回答

显然你想:

sudo /Library/StartupItems/MySQLCOM/MySQLCOM stop

你可以进一步阅读《Jeez People,停止为安装RMagic而烦恼》。

其他回答

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

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

显然你想:

sudo /Library/StartupItems/MySQLCOM/MySQLCOM stop

你可以进一步阅读《Jeez People,停止为安装RMagic而烦恼》。

Mysql >显示变量variable_name为'%dir%';

| datadir | / opt / local / var / db / mysql5 / |

我在macports上安装了mysql5和mysql55。对我来说,这里提到的文件位于以下位置:

(mysql55-server) / opt /地方/ etc / LaunchDaemons / org.macports.mysql55-server / org.macports.mysql55-server.plist

(mysql5) / opt / local / etc / LaunchDaemons - org . macports mysql5 mysql5 - org . macports。plist

所以停下来是这样做的:

mysql55-server:

sudo launchctl unload -w /opt/local/etc/LaunchDaemons/org.macports.mysql55-server/org.macports.mysql55-server.plist

mysql5:

sudo launchctl unload -w /opt/local/etc/LaunchDaemons/org.macports.mysql5/org.macports.mysql5.plist 

您可以检查服务是否仍在运行:

ps ax | grep mysql

此外,你可以在我的案例中查看日志文件:

mysql55-server

sudo tail -n 100 /opt/local/var/db/mysql55/<MyName>-MacBook-Pro.local.err
...
130213 08:56:41 mysqld_safe mysqld from pid file /opt/local/var/db/mysql55/<MyName>-MacBook-Pro.local.pid ended

mysql5:

sudo tail -n 100 /opt/local/var/db/mysql5/<MyName>-MacBook-Pro.local.err
...
130213 09:23:57  mysqld ended

在我的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文件来运行