停止

brew services stop mysql@5.7

sudo mysqld_safe --skip-grant-tables

另起一个终端, 输入

mysql

命令

use mysql;
update user set authentication_string=password('root654321') where Host='localhost' and User='root';
exit

启动

brew services start mysql@5.7