问题描述
我使用自制软件brew install mysql
安装了MySQL,我注意到可以使用两种不同的方法来管理MySQL:
I installed MySQL using homebrew brew install mysql
, and I noticed that MySQL can be managed with two different methods:
brew services start mysql
和mysql.server start
brew services start mysql
and mysql.server start
使用brew服务启动服务与使用常规mysql.server方法启动服务有什么区别吗?还是它们基本上是同一件事,只是别名不同?
Is there any difference when starting the service using brew services vs starting it with the normal mysql.server method? Or are they basically the same thing, just a different alias?
似乎它们都使用相同的可执行文件:/usr/local/Cellar/mysql/5.7.17/bin/mysqld
It appears they both use the same executable: /usr/local/Cellar/mysql/5.7.17/bin/mysqld
谢谢您的帮助!
推荐答案
根据brew services
的帮助消息,在运行时
According to the help message of brew services
, when you run
brew services start mysql
它将在登录时安装并启动服务公式(如果使用sudo
运行该命令,则启动该服务).这意味着您现在将在~/Library/LaunchAgents
中(或如果在sudo
中运行命令的情况下,在/Library/LaunchDaemons
中)将有一个plist文件.对于mysql,plist文件如下:
it installs and starts the service formula at login (or boot if you run the command with sudo
). It means you will have now a plist file in ~/Library/LaunchAgents
(or in /Library/LaunchDaemons
if you run the command with sudo
). For mysql, the plist file is the following:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>homebrew.mxcl.mysql</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/opt/mysql/bin/mysqld_safe</string>
<string>--bind-address=127.0.0.1</string>
<string>--datadir=/usr/local/var/mysql</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>WorkingDirectory</key>
<string>/usr/local/var/mysql</string>
</dict>
</plist>
这意味着默认情况下,mysqld_safe
是通过--bind-address=127.0.0.1
和--datadir=/usr/local/var/mysql
命令行选项调用的.
it means that by default mysqld_safe
is called with the --bind-address=127.0.0.1
and --datadir=/usr/local/var/mysql
command line options.
跑步时
mysql.server start
您直接执行/usr/local/bin/mysql.server
中的mysql脚本.
you directly execute the mysql script located in /usr/local/bin/mysql.server
.
主要区别在于,使用brew services
版本时,您将运行mysqld_safe
,根据其man
页面:
The main difference is that with the brew services
version, you run mysqld_safe
which, according to its man
page:
这篇关于酿造服务启动mysql和mysql.server启动之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!