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


当前回答

我在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

其他回答

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

也就是说,

ps -Af

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

你可以使用命令"mysqladmin shutdown"

对我来说,以下解决方案无法在OS X 10.10上停止MySQL

停止自动启动我使用:

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

并关闭我使用的服务:

sudo pkill mysqld

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包。