1.安装mysql
brew install mysql
提示:We’ve installed your MySQL database without a root password.
2.给root用户设置密码
##To connect run
mysql -u root
##设置密码
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'a12345678*';
3.启动服务
brew services start mysql
4.密码登录
mysql -u root -p
5.退出登录
exit
6.重启服务
brew services restart mysql
7.关闭服务
brew services stop mysql