安装MySql
$ brew install mysql
设置MySql开机启动
$ mkdir -p ~/Library/LaunchAgents # 首先确认该目录是否存在,若已经存在不用执行本命令 $ ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents $ launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
启动MySql服务
$ mysql.server start
错误修复
如果在启动过程中出现如下错误:ERROR! The server quit without updating PID file,使用以下方法修复。
$ sudo chmod -R 755 /usr/local/var/mysql
若仍不能启动,tail -f …pid 查看pid.err保错文件
InnoDB: Table flags are 0 in the data dictionary but the flags in file ./ibdata1 are 0x4800!
先前安装的mysql8创建了坏的DB文件,必须手动删除 rm -rf /usr/local/var/mysql brew uninstall mysql@5.7 brew install mysql@5.7
使用Homebrew卸载MySql
$ brew remove mysql $ brew cleanup $ launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist $ rm -Rf ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
来源:51CTO
作者:zkpython
链接:https://blog.csdn.net/zkpython/article/details/100770257