1.修改配置文件
1.修改配置文件
--- vim /etc/my.cnf
在 [mysqld] 的段中加上一句:skip-grant-tables
2.重启mysql
--- systemctl restart mysqld
3.修改密码
--- use mysql;
--- update user set authentication_string=password('new password') where user = 'root';
退出,再次进入
4.设置密码
--- use mysql;
--- set global validate_password_policy=0;
--- set global validate_password_length=1;
--- alter user 'root'@'localhost' identified by 'new password';
退出,
5.还原配置文件
--- vim /etc/my.cnf
注释掉原本的:skip-grant-tables