如何在OS X Yosemite/El Capitan上启动时自动加载MySQL [英] How to auto-load MySQL on startup on OS X Yosemite / El Capitan

查看:65
本文介绍了如何在OS X Yosemite/El Capitan上启动时自动加载MySQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

After upgrading OS X my install of MySQL stopped loading on startup.

在MySQL上逐步演练说:

启动项目安装将变量MYSQLCOM = -YES-添加到 系统配置文件/etc/hostconfig.如果要禁用 自动启动MySQL,将此变量更改为MYSQLCOM = -NO-."

"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-."

因此,我打开了该文件,并显示:

So, I opened that file and it says:

# This file is going away 
AFPSERVER=-NO- 
AUTHSERVER=-NO-
TIMESYNC=-NO-
QTSSERVER=-NO-
MYSQLCOM=-YES-

我认为OSX开发人员已经添加了# This file is going away,但我不确定.

I assume OSX dev's added the # This file is going away but I'm not certain.

如果是这样,在OSX Yosemite上启动时启动MySQL的正确方法是什么?

If that is the case, what is the proper way to start MySQL on startup on OSX Yosemite?

推荐答案

这是解决问题的方法:

首先,创建一个新文件:/Library/LaunchDaemons/com.mysql.mysql.plist

First, create a new file: /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:

Then update permissions and add it to 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

这篇关于如何在OS X Yosemite/El Capitan上启动时自动加载MySQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆