【问题标题】:MySQL LaunchDaemon not running on macOS El Capitan ServerMySQL LaunchDaemon 未在 macOS El Capitan Server 上运行
【发布时间】:2018-01-13 00:38:28
【问题描述】:

我已经通过自制软件和instructions 安装了 MySQL。 homebrew 安装的服务是 LaunchAgent,它工作正常,但仅在我的用户登录时运行。我希望 MySQL 始终运行。

我尝试将homebrew.mxcl.mysql.plist 复制到/Library/LaunchAgents,将权限设置为644 root:wheel,并使用sudo launchctl -w /Library/LaunchAgents/homebrew.mxcl.mysql.plist 加载。虽然sudo launchctl list显示plist已加载,状态为0,但没有PID。当我运行ps aux | grep mysql 时,我没有看到任何相关进程。

手动运行命令有效:/usr/local/opt/mysql/bin/mysqld_safe --datadir=/usr/local/var/mysql --bind-address=0.0.0.0 但如果用户注销,MySQL 将退出。

已经有一个related question on stackoverflow,但似乎每个人都在回答如何通过LaunchAgent添加服务,runs at login rather than at boot

/Library/LaunchDaemons/homebrew.mxcl.mysql.plist

<?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>--datadir=/usr/local/var/mysql</string>
    <string>--bind-address=0.0.0.0</string>
  </array>
  <key>RunAtLoad</key>
  <true/>
  <key>WorkingDirectory</key>
  <string>/usr/local/var/mysql</string>
</dict>
</plist>

ps辅助

nperkins$ sudo ps aux | grep mysql
nperkins        15345   0.0  0.0  2444056    816 s001  S+    7:02PM   0:00.00 grep mysql

Launchctl 列表

nperkins$ sudo launchctl list | grep mysql
-   0   homebrew.mxcl.mysql

【问题讨论】:

    标签: mysql homebrew launchd launchctl


    【解决方案1】:

    我想通了。 LaunchDaemon plist 正在运行并试图每五秒保持一次活动,但 mysqld_safe 在启动时阻塞,因为数据文件夹 /usr/local/var/mysql 不在 _mysql 组中。我将该文件夹的所有权更改为_mysql:wheel,现在它可以工作了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-03-11
      • 1970-01-01
      • 2016-02-01
      • 2016-11-20
      • 2017-07-09
      • 1970-01-01
      • 2017-01-15
      • 2016-11-02
      相关资源
      最近更新 更多