我正在使用launchd在启动时启动mysql,它工作正常。我可以使用“ launchctl卸载”和“ launchctl加载”命令停止和启动服务。我也可以通过在终端中键入“ mysqld_safe”命令来启动服务。但是,如果我通过“ launchctl stop”停止服务,然后通过“ mysqld_safe”命令启动服务,则无法通过“ launchctl stop”停止服务。这可能吗?我在这里做错了什么?
我的清单是:
<?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>Label</key>
<string>mysql.service</string>
<key>ProgramArguments</key>
<array>
<string>/path/to/mysql/bin/mysqld_safe</string>
<string>--defaults-file=/path/to/mysql/my.cnf</string>
<string>--port=3306</string>
<string>--socket=/path/to/mysql/tmp/mysql.sock</string>
<string>--datadir=/path/to/mysql/data</string>
<string>--log-error=/path/to/mysql/data/mysqld.log</string>
<string>--pid-file=/path/to/mysql/data/mysqld.pid</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<false/>
<key>UserName</key>
<string>_mysql</string>
<key>GroupName</key>
<string>_mysql</string>
<key>StandardOutPath</key>
<string>/tmp/mysql_start.out</string>
<key>StandardErrorPath</key>
<string>/tmp/mysql_start.err</string>
</dict>
</plist>
通过终端启动mysql的命令是:
mysqld_safe --defaults-file=/path/to/mysql/my.cnf --port=3306 --socket=/path/to/mysql/tmp/mysql.sock --datadir=/path/to/mysql/data --pid-file=/path/to/mysql/data/mysqld.pid