第一步:修改 /etc/mysql/my.cnf。
在【mysql】下添加skip-grant-table;重啟。
第二步:通過mysql命令登陸;
flush privileges;
use mysql;
alter user 'root'@'localhost' identified with mysql_native_password by 'Newpassword@123';(不確定的要求:新密碼需要字母大小寫+特殊字符)
flush privileges;
再把skip-grant-table去掉;重啟。
最后一步:msyql -uroot -p登陸(不能直接 -pNewpassword@123)
