1、进入到MySQL安转bin目录下:
cd /opt/homebrew/Cellar/mysql@5.7/5.7.41/bin
2、启动安全模式,并进入MySQL:
mysqld_safe --skip-grant-tables
mysql -u root -p
3、修改root账户密码:
update mysql.user set authentication_string=PASSWORD('123456') where user='root';
flush privileges;
exit
4、再次进入MySQL,重置密码:
mysql -u root -p 123456
set password for root@localhost=password('123456');