我通过MacPorts安装了MySQL .我需要什么命令来停止服务器(我需要测试我的应用程序在MySQL死机时的行为)?
根据您是使用官方二进制安装程序,使用MacPorts还是使用Homebrew安装MySQL,有不同的情况:
sudo launchctl unload -w /Library/LaunchDaemons/org.macports.mysql.plist sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql.plist
注意:重启后这是持久的.
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
sudo /Library/StartupItems/MySQLCOM/MySQLCOM stop sudo /Library/StartupItems/MySQLCOM/MySQLCOM start sudo /Library/StartupItems/MySQLCOM/MySQLCOM restart
对于那些使用自制软件安装MySQL的人,请使用以下命令启动,停止或重启MySQL
酿造开始
/usr/local/bin/mysql.server start
Brew重启
/usr/local/bin/mysql.server restart
酿造停止
/usr/local/bin/mysql.server stop
你总是可以使用命令"mysqladmin shutdown"
如果您正在使用,homebrew
您可以使用
brew services restart mysql brew services start mysql brew services stop mysql
获取可用服务列表
brew services list
sudo /usr/local/mysql/support-files/mysql.server停止
sudo /opt/local/etc/LaunchDaemons/org.macports.mysql5/mysql5.wrapper stop
您也可以在此处使用启动和重启.我通过查看/Library/LaunchDaemons/org.macports.mysql.plist的内容找到了这个.
显然你想要:
sudo /Library/StartupItems/MySQLCOM/MySQLCOM stop
在Jeez People中进一步阅读,停止安装RMagic.
尝试
sudo/support-files/mysql.server start sudo /support-files/mysql.server stop
其他尝试:
sudo /Library/StartupItems/MySQLCOM/MySQLCOM start sudo /Library/StartupItems/MySQLCOM/MySQLCOM stop
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
在我的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文件来运行
使用:
sudo mysqladmin shutdown --user=*user* --password=*password*
人们可能会因为不使用sudo而逃脱.例如,用户可以是root 用户(即MySQL root用户).