1、更改/etc/my.cnf文件

vi /etc/my.cnf,在[mysqld]中添加
skip-grant-tables

2、重启MySQL服务

service mysqld restart

3、使用用户无密码登录

mysql -uroot -p (直接点击回车,密码为空)

4、选择数据库

use mysql;

5、修改密码

update user set authentication_string=password(‘123456’) where user=‘root’;

6、刷新权限

flush privileges;

7、退出

exit

8、删除第1部增加的配置信息,并重启MySQL服务

Centos7中MySQL忘记密码处理方法

相关文章:

  • 2021-07-04
  • 2022-12-23
  • 2021-09-22
  • 2022-12-23
  • 2021-06-22
  • 2021-12-25
  • 2021-05-21
  • 2021-11-26
猜你喜欢
  • 2021-12-04
  • 2022-12-23
  • 2021-11-28
  • 2021-12-04
  • 2021-12-14
相关资源
相似解决方案