mysql - 如何在 OS X Yosemite/El Capitan 上启动时自动加载 MySQL

标签 mysql macos osx-yosemite startup osx-elcapitan

升级 OS X 后,我安装的 MySQL 在启动时停止加载。

这个 walk-through on 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/

相关文章:

mysql - 从表中仅选择具有最高日期时间值的一行

c# - 我可以使用 xcode 在 C# 中编程吗?

macos - Cocoa:[self.view setWantsLayer:YES] 将该 View 置于其他 subview 之上?

mongodb - 如何检查 mongo db 是否在 Mac 上运行?

macos - 与应用程序扩展的核心数据并发

用于动态显示来自mysql的10条记录的PHP代码

mysql - SQL语句命名3个id标签

mysql - 在 node.js 上单元测试 mysql 回滚

windows - 有没有办法在 Windows 系统和 MacOS 都兼容的 PowerShell 中显示弹出消息框?

macos - 无法匹配包含自定义 View 的 Yosemite NSMenuItem 的鲜艳背景