我已經通過自制軟件安裝了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