我通过MacPorts安装了MySQL 。我需要停止服务器的命令是什么(我需要测试MySQL死后应用程序的行为)?
我通过MacPorts安装了MySQL 。我需要停止服务器的命令是什么(我需要测试MySQL死后应用程序的行为)?
Answers:
根据您是使用正式的二进制安装程序,使用MacPorts还是使用Homebrew安装MySQL的情况不同:
brew services start mysql
brew services stop mysql
brew services restart mysql
sudo port load mysql57-server
sudo port unload mysql57-server
注意:重新启动后,此设置将持续存在。
sudo /Library/StartupItems/MySQLCOM/MySQLCOM stop
sudo /Library/StartupItems/MySQLCOM/MySQLCOM start
sudo /Library/StartupItems/MySQLCOM/MySQLCOM restart
launchctl (un)load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
brew services stop mysql
和brew services start mysql
。(也是restart
,并且run
仅在当前会话开始。)
对于使用自制软件安装MySQL的用户,请使用以下命令启动,停止或重新启动MySQL
冲泡开始
/usr/local/bin/mysql.server start
重新启动冲泡
/usr/local/bin/mysql.server restart
冲泡停止
/usr/local/bin/mysql.server stop
/usr/local/Cellar/mysql@5.7/5.7.23/bin/
您可以随时使用命令“ mysqladmin shutdown”
sudo /opt/local/lib/mysql56/bin/mysqladmin shutdown
如果您的MySQL来自MacPorts
如果您正在使用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 <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卸载-w /Library/LaunchDaemons/com.mysql.mysqld.plist
在我的Mac OS X优胜美地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文件
mysqld
过程将在停止后立即重新启动。
好吧,如果其他所有方法都失败了,您可以采取无情的方法并手动终止运行MySQL的进程。
那是,
ps -Af
列出所有进程,然后执行“ kill <pid>
”,其中<pid>
MySQL守护进程(mysqld)的进程ID 在哪里。
最新的OSX(10.8)和mysql 5.6,该文件位于Launch Daemons下,并且位于com.oracle.oss.mysql.mysqld.plist。它在“系统选项”下显示一个选项,通常在列表的底部。因此,请转到系统设置,单击Mysql,然后从选项框中将其关闭。 https://dev.mysql.com/doc/refman/5.6/zh-CN/osx-installation-launchd.html
我在macports上安装了mysql5和mysql55。对我来说,这里提到的文件位于以下位置:
(mysql55服务器)/opt/local/etc/LaunchDaemons/org.macports.mysql55-server/org.macports.mysql55-server.plist
(mysql5)/opt/local/etc/LaunchDaemons/org.macports.mysql5/org.macports.mysql5.plist
所以停止这些工作是这样的:
mysql55服务器:
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服务器
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
如果您在MacPorts上安装了MySQL 5软件包:
sudo launchctl unload -w /Library/LaunchDaemons/org.macports.mysql.plist
要么
sudo launchctl unload -w /Library/LaunchDaemons/org.macports.mysql5-devel.plist
如果安装了mysql5-devel
软件包。
在尝试所有这些命令行后,它是行不通的。我必须做以下事情:
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.