brew安装mysql为系统服务

默认情况下,使用brew install mysql 安装完mysql以后,需要手动启动mysql。为了方便以后使用,这里将mysql安装成系统服务。

brew info mysql 已经给了.plist文件,只需要load一下就可以,plist文件名不一定是com.mysql.mysqld.plist, 可以先到 `brew –prefix mysql` 目录看下。具体如下:

mkdir -p ~/Library/LaunchAgents
cp `brew --prefix mysql`/com.mysql.mysqld.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/com.mysql.mysqld.plist

其实http://stackoverflow.com/questions/8014500/autostart-mysql-on-boot-from-terminal这里有说。

mkdir -p ~/Library/LaunchAgents
cp `brew --prefix mysql`/*mysql*.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/*mysql*.plist