1、修改配置文件 vim /etc/my.cnf
vim /etc/my.cnf
2、添加一行数据 skip-grant-tables【一定要在[mysqld]下添加】
skip-grant-tables
3、保存退出(:wq)
4、重启服务
service mysqld restart
5、免密登陆
mysql
6、进入mysql数据库
use mysql
7、重置密码
update user set authentication_string=password('root') where user='root';
8、应用配置
flush privileges;
9、注释掉免验证代码
vim /etc/my.cnf #skip-grant-tables
10、重启服务
>service mysqld restart
centos重置mysql密码
最新推荐文章于 2023-05-18 10:01:42 发布