cd /opt/Homebrew/opt/mysql@5.7/bin
brew services stop mysql@5.7
./mysqld -nt --skip-grant-tables
#另起一个cmd
./mysql -uroot -p
# 直接点击回车,密码为空
# 在5.7版本中不存在password字段
update mysql.user set authentication_string=password('123456') where user='root' and host='localhost';
# 刷新权限
flush privileges;
exit
brew services start mysql@5.7