- 停止MySQL服务
sudo /usr/local/mysql/support-files/mysql.server stop
- 禁止mysql验证功能(先获取管理员权限)
cd /usr/local/mysql/bin/
sudo su
./mysqld_safe --skip-grant-tables &
上述步骤后mysql会自动重启
- 进入mysql重设密码
./mysql
FLUSH PRIVILEGES;
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '1234';