2017-08-05 78 views
1

我已经通过自制软件安装了MySQL,并且这些安装了instructions。自制软件安装的服务是LaunchAgent,它可以正常运行,但只能在我的用户登录时运行。我希望MySQL始终处于运行状态。MySQL LaunchDaemon未在macOS上运行El Capitan服务器

我试过将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 aux

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 

回答

0

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