终端下执行
mysql.server start
mysql.server stop
mysql.server restart
用brew安装的可以通过以下语句查看安装目录:
brew --prefix mysql
从你mysql的安装目录下找到homebrew.mxcl.mysql.plist这个文件,然后复制到~/Library/LaunchAgents目录下,然后在终端执行以下语句即可:
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
那么问题来了,有的小伙伴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=root</string>
</array>
</dict>
</plist>
其中/ust/local/opt/mysql是我的mysql安装目录,替换成你自己的就可以 最后,执行以下语句
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
注:这里的文件名以你mysql目录下的名字,或者你自己创建时起的名字为准
viencoding.com版权所有,允许转载,但转载请注明出处和原文链接: https://viencoding.com/article/11附:Mac OS X的启动原理:mac固件激活,初始化硬件,加载BootX引导器。BootX加载内核与内核扩展(kext)。内核启动launchd进程。launchd根据 /System/Library/LaunchAgents, /System/Library/LaunchDaemons , /Library/LaunchDaemons,/Library/LaunchAgents , ~/Library/LaunchAgents里的plist配置,启动服务守护进程。