我已经通过自制软件和instructions安装了MySQL。自制软件安装的服务是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 aux
nperkins$ sudo ps aux | grep mysql
nperkins 15345 0.0 0.0 2444056 816 s001 S+ 7:02PM 0:00.00 grep mysql
启动列表
nperkins$ sudo launchctl list | grep mysql
- 0 homebrew.mxcl.mysql
答案 0 :(得分:0)
我想出来了。 LaunchDaemon plist正在运行,并且每隔五秒钟试图保持活动状态,但是mysqld_safe在启动时窒息,因为数据文件夹/usr/local/var/mysql
不在_mysql
组中。我将该文件夹的所有权更改为_mysql:wheel
,现在可以正常使用。