酿造服务启动mysql和mysql.server启动之间的区别 [英] Difference between `brew services start mysql` and `mysql.server start`

查看:107
本文介绍了酿造服务启动mysql和mysql.server启动之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用自制软件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:

添加了一些安全功能,例如在发生错误时重新启动服务器以及将运行时信息记录到错误日志文件中.

adds some safety features such as restarting the server when an error occurs and logging runtime information to an error log file.

这篇关于酿造服务启动mysql和mysql.server启动之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆