本文发自 http://www.binss.me/blog/mysql-server-cannot-boot-on-yosemite/,转载请注明出处。

升到了10.10后,遇到的第一个问题就是这个。

在stackoverflow上找到了解决方法:

http://stackoverflow.com/questions/26461173/autostart-mysql-server-on-mac-os-x-yosemite/26465743#26465743

中文版:

在/Library/LaunchDaemons新建一个名为com.mysql.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>com.mysql.mysqld</string>
    <key>ProgramArguments</key>
    <array>
    <string>/usr/local/mysql/bin/mysqld_safe</string>
    <string>--user=mysql</string>
    </array>
  </dict>
</plist>

保存后设置文件属性:

sudo chown root /Library/LaunchDaemons/com.mysql.mysql.plist
sudo chgrp 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 server就又像往常一样能够开机自启动了~