创建启动目录,如果没有的话
mkdir -p ~/Library/LaunchAgents
将启动文件拷贝进去
% cp /opt/homebrew/Cellar/mysql@5.7/5.7.34/homebrew.mxcl.mysql@5.7.plist ~/Library/LaunchAgents
设置开启启动
% launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql@5.7.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>homebrew.mxcl.mysql@5.7</string>
<key>ProgramArguments</key>
<array>
<string>/opt/homebrew/opt/mysql@5.7/bin/mysqld_safe</string>
<string>--datadir=/opt/homebrew/var/mysql</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>WorkingDirectory</key>
<string>/opt/homebrew/var/mysql</string>
</dict>
</plist>