标签:dia doctype 操作 启动 ack tar array plist dtd
在上一篇文章http://www.cnblogs.com/EasonJim/p/6275863.html中安装MySQL时采用的时DMG包的安装步骤页面进行安装的,如果这样安装的MySQL是会开机自启动,并且在系统设置中有MySQL关于服务方面的快速操作界面。
那么如果是基于二进制包安装的,如果要实现开机自启动,那么需要使用到Launchd进行服务的管理。
实现步骤:
1、在/Library/LaunchDaemons下新建com.oracle.oss.mysql.mysqld.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>Disabled</key> <false/> <key>ExitTimeOut</key> <integer>600</integer> <key>GroupName</key> <string>_mysql</string> <key>KeepAlive</key> <true/> <key>Label</key> <string>com.oracle.oss.mysql.mysqld</string> <key>LaunchOnlyOnce</key> <false/> <key>ProcessType</key> <string>Interactive</string> <key>Program</key> <string>/usr/local/mysql/bin/mysqld</string> <key>ProgramArguments</key> <array> <string>/usr/local/mysql/bin/mysqld</string> <string>--user=_mysql</string> <string>--basedir=/usr/local/mysql</string> <string>--datadir=/usr/local/mysql/data</string> <string>--plugin-dir=/usr/local/mysql/lib/plugin</string> <string>--log-error=/usr/local/mysql/data/mysqld.local.err</string> <string>--pid-file=/usr/local/mysql/data/mysqld.local.pid</string> </array> <key>RunAtLoad</key> <true/> <key>SessionCreate</key> <true/> <key>UserName</key> <string>_mysql</string> <key>WorkingDirectory</key> <string>/usr/local/mysql</string> </dict> </plist>
提示:创建文件可以使用vi命令这些,注意要加上sudo开头。
2、修改权限:
sudo chown root:wheel com.oracle.oss.mysql.mysqld.plist
3、检查语法
sudo plutil -lint com.oracle.oss.mysql.mysqld.plist
4、加载
sudo launchctl load -w com.oracle.oss.mysql.mysqld.plist
提示:这样设置完成之后就可以开机自启动。
5、卸载,取消开机自启动
sudo launchctl unload -w com.oracle.oss.mysql.mysqld.plist
删除com.oracle.oss.mysql.mysqld.plist
参考:
http://blog.csdn.net/lolashe/article/details/41117577
http://squll369.iteye.com/blog/1965185
http://www.cnblogs.com/EasonJim/p/7173859.html(基本服务命令操作)
https://en.wikipedia.org/wiki/Launchd(plist语法参考)
Mac 10.12通过Launchd创建自定义服务(基于MySQL 5.7.15的开机自启动)
标签:dia doctype 操作 启动 ack tar array plist dtd
原文地址:http://www.cnblogs.com/EasonJim/p/7173927.html