1.在 /etc/my.cnf 中的 [mysqld] 中添加 skip-grant-table 
2.使用 [root]# server mysql restart 重启服务
3.输入 [root]# mysql 无密码登录到mysql中
4.使用 mysql > use mysql #选择数据库
5.使用 mysql > update user set authentication_string='' where user='root'; #将root的权限验证字符串更新为空
6.使用 mysql > select Host,User,authentication_string from user; #查询是否更新成功
7.使用 mysql > flush privileges #刷新权限
8.使用 mysql > exit #退出MySQL
9.在配置文件[root]# vim /etc/my.cnf 中注释  #skip-grant-table 
10.重复第2步骤 重启服务
11.使用 [root]# mysql -uroot -p 后直接回车登录到MySQL中 【注意其他语句可能有兼容问题导致【Mysql8.0】ERROR 1820 (HY000): You must reset your password using ALTER USER statement】
12.使用 mysql > set password='your password'; #输入密码 
13.重复第7步。

相关文章:

  • 2021-08-14
  • 2021-11-20
  • 2021-12-20
  • 2022-02-23
  • 2022-01-22
  • 2021-09-08
  • 2021-06-16
  • 2021-12-05
猜你喜欢
  • 2021-11-21
  • 2021-11-20
  • 2022-12-23
  • 2021-05-03
  • 2021-08-26
  • 2022-12-23
相关资源
相似解决方案