系统环境

MacOs 13.4.1 (c) (22F770820d)

1.停止mysql service

1
sudo /usr/local/mysql/support-files/mysql.server stop

2.开启mysql的”安全模式”

1
2
3
4
cd /usr/local/mysql/bin/
sudo su
./mysqld_safe --skip-grant-tables &
./mysql

3.刷新权限 &修改密码

1
2
FLUSH PRIVILEGES;
ALTER USER 'root'@'localhost' IDENTIFIED BY '新密码';

4.重启mysql,登录验证是否成功

1
2
sudo /usr/local/mysql/support-files/mysql.server restart
/usr/local/mysql/bin/mysql -u root -p