一、执行sudo vim /etc/my.cnf

加入 skip-grant-tables

linux下mysql忘记root密码!

 二、重新启动mysql

sudo service mysql restart

linux下mysql忘记root密码!

三、执行mysql -uroot -p(不需要密码直接Enter)

linux下mysql忘记root密码!

四、sql语句修改密码

USE mysql ;

UPDATE user SET Password = password ( 'new-password' ) WHERE User = 'root' ; 

linux下mysql忘记root密码!

 五、执行quit退出mysql

 六、重新执行sudo vim /etc/my.cnf,然后删除刚刚加入的 skip-grant-tables,重新启动mysql

相关文章:

  • 2021-06-04
  • 2021-08-22
  • 2021-10-26
  • 2021-09-18
  • 2022-02-28
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-07
  • 2022-02-10
  • 2021-12-01
  • 2022-01-06
相关资源
相似解决方案