升级 OS X 后,我安装的 MySQL 在启动时停止加载。
"The Startup Item installation adds a variable MYSQLCOM=-YES- to the system configuration file /etc/hostconfig. If you want to disable the automatic startup of MySQL, change this variable to MYSQLCOM=-NO-."
所以,我打开了那个文件,上面写着:
# This file is going away
AFPSERVER=-NO-
AUTHSERVER=-NO-
TIMESYNC=-NO-
QTSSERVER=-NO-
MYSQLCOM=-YES-
我假设 OSX 开发人员添加了 # This file is going away
但我不确定。
如果是这样,在 OSX Yosemite 上启动 MySQL 的正确方法是什么?
最佳答案
这是修复它的原因:
首先,新建一个文件:/Library/LaunchDaemons/com.mysql.mysql.plist
<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true />
<key>Label</key>
<string>com.mysql.mysqld</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/mysql/bin/mysqld_safe</string>
<string>--user=mysql</string>
</array>
</dict>
</plist>
然后更新权限并添加到launchctl
:
sudo chown root:wheel /Library/LaunchDaemons/com.mysql.mysql.plist
sudo chmod 644 /Library/LaunchDaemons/com.mysql.mysql.plist
sudo launchctl load -w /Library/LaunchDaemons/com.mysql.mysql.plist
关于mysql - 如何在 OS X Yosemite/El Capitan 上启动时自动加载 MySQL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26476391/