我已经通过自制软件安装了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