如何在 Mac OS 安装上停止 MySQL?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/100948/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 12:03:45  来源:igfitidea点击:

How do you stop MySQL on a Mac OS install?

mysqlmacos

提问by Laurie Young

I installed MySQL via MacPorts. What is the command I need to stop the server (I need to test how my application behave when MySQL is dead)?

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

回答by mloughran

There are different cases depending on whether you installed MySQLwith the official binary installer, using MacPorts, or using Homebrew:

根据您是使用官方二进制安装程序、使用MacPorts还是使用Homebrew安装MySQL,有不同的情况:

MacPorts

端口

sudo port load mysql57-server
sudo port unload mysql57-server

Note: this is persistent after a reboot.

注意:这在重新启动后是持久的。

Homebrew

家酿

launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist

Binary installer

二进制安装程序

sudo /Library/StartupItems/MySQLCOM/MySQLCOM stop
sudo /Library/StartupItems/MySQLCOM/MySQLCOM start
sudo /Library/StartupItems/MySQLCOM/MySQLCOM restart

回答by pjammer

For those who used homebrew to install MySQL use the following commands below to start, stop, or restart MySQL

对于使用自制软件安装 MySQL 的用户,请使用以下命令来启动、停止或重新启动 MySQL

Brew start

酿造开始

/usr/local/bin/mysql.server start

Brew restart

酿造重启

/usr/local/bin/mysql.server restart

Brew stop

酿造停止

/usr/local/bin/mysql.server stop

回答by Rimantas

You can always use command "mysqladmin shutdown"

您始终可以使用命令“mysqladmin shutdown”

回答by Jan

If you are using homebrewyou can use

如果您正在使用,homebrew您可以使用

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

for a list of available services

获取可用服务列表

brew services list

回答by Moesio

sudo /usr/local/mysql/support-files/mysql.server stop

须藤/usr/local/mysql/support-files/mysql.server 停止

回答by katy lavallee

sudo /opt/local/etc/LaunchDaemons/org.macports.mysql5/mysql5.wrapper stop

sudo /opt/local/etc/LaunchDaemons/org.macports.mysql5/mysql5.wrapper stop

You can also use start and restart here. I found this by looking at the contents of /Library/LaunchDaemons/org.macports.mysql.plist.

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

回答by Dan

Apparently you want:

显然你想要:

sudo /Library/StartupItems/MySQLCOM/MySQLCOM stop

Have a further read in Jeez People, Stop Fretting Over Installing RMagic.

进一步阅读Jeez People,停止为安装 RMagic 而烦恼

回答by zack

Try

尝试

sudo <path to mysql>/support-files/mysql.server start
sudo <path to mysql>/support-files/mysql.server stop

Else try:

其他尝试:

sudo /Library/StartupItems/MySQLCOM/MySQLCOM start
sudo /Library/StartupItems/MySQLCOM/MySQLCOM stop<br>
sudo /Library/StartupItems/MySQLCOM/MySQLCOM restart

However, I found that the second option only worked (OS X 10.6, MySQL 5.1.50) if the .plist has been loaded with:

但是,我发现如果 .plist 已加载,则第二个选项仅适用(OS X 10.6,MySQL 5.1.50):

sudo launchctl load -w /Library/LaunchDaemons/com.mysql.mysqld.plist

PS: I also found that I needed to unload the .plist to get an unrelated install of MAMP-MySQL to start / stop correctly. After running running this, MAMP-MySQL starts just fine:

PS:我还发现我需要卸载 .plist 才能获得无关的MAMP-MySQL安装才能正确启动/停止。运行运行后,MAMP-MySQL 启动得很好:

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

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

回答by Duc Chi

On my mac osx yosemite 10.10. This command worked:

在我的 mac osx 优胜美地 10.10 上。此命令有效:

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

You can find your mysql file in folder /Library/LaunchDaemons/ to run

您可以在文件夹 /Library/LaunchDaemons/ 中找到您的 mysql 文件来运行

回答by Steve

Use:

用:

sudo mysqladmin shutdown --user=*user* --password=*password*

One could probably get away with not using sudo. The usercould be root for example (that is, the MySQL root user).

不使用sudo可能会逃脱。例如,用户可以是 root(即 MySQL root 用户)。