修改my.cnf

[mysqld] 域中添加skip-grant-tables

重启mysqld服务

systemctl restart mysqld

重新使用空密码登录,直接敲回车

mysql -u root -p

切换数据库,并将密码清空

mysql >use mysql;
mysql >update user set authentication_string = '' where user = 'root';

退出

mysql >quit

删除my.cnf中的skip-grant-tables,并重启服务

systemctl restart mysqld

重新登录root账号,密码直接回车

修改root密码

mysql >ALTER USER 'root'@'localhost' IDENTIFIED BY '新密码';

 

相关文章:

  • 2021-12-22
  • 2021-09-27
  • 2021-11-20
  • 2021-12-12
  • 2021-10-09
  • 2022-12-23
  • 2022-01-04
  • 2021-12-06
猜你喜欢
  • 2021-10-01
  • 2021-04-27
  • 2021-09-04
  • 2021-09-03
  • 2021-09-03
相关资源
相似解决方案