1.停止mysql 服务:service mysqld stop;

2.vim命令打开mysql配置文件my.cnf(位置一般为:/etc/my.cnf)

3.在mysqld进程配置文件中添加skip-grant-tables,添加完成后保存。

4.重新打开mysql服务:service mysqld stop;

5.登陆mysql:mysql -u root -p; 不用输入密码登录mysql;

6.update user  set password=password('newpassword') where user='root' (5.7以前版本)

  update user  set authentication_string=password('newpassword') where user='root' (5.7及以后版本)

 

7.在mysqld进程配置文件中注释skip-grant-tables,添加完成后保存

 

8.重启mysql服务

相关文章:

  • 2021-05-13
  • 2021-10-09
  • 2021-06-19
  • 2021-08-08
  • 2022-01-25
猜你喜欢
  • 2021-11-28
  • 2022-12-23
  • 2021-05-01
  • 2021-06-10
  • 2021-10-09
  • 2021-12-13
  • 2021-06-15
相关资源
相似解决方案