编程爱好者之家
1. vi /etc/my.cnf,在[mysqld]中添加
skip-grant-tables
2.重启mysql,然后用无密码登录
systemctl restart mysqld mysql -uroot -p (直接点击回车,密码为空)
3.进入数据库更改密码,刷新权限
use mysql; update user set authentication_string=password('新密码') where user='root'; flush privileges;
4.最后删除1中添加的'skip-grant-tables',然后重启mysql即可