1) 修改my.cnf文件

添加如下一行

skip-grant-tables
skip-networking

2)重启mysql

3) 登陆mysql 

mysql -uroot -p #回车

#回车

会直接进入mysql命令行

 

4)设置新的root密码
如下命令

update mysql.user set authentication_string=password("mynew_password") where user="root" and host="localhost"

 

5)密码修改成功修改my.cnf

移除

skip-grant-tables
skip-networking

 

6) 重启mysql

 

7) 尝试用修改后的密码登陆

mysql -uroot -pmynew_password

 

 正常进入mysql的情况下修改密码

ALTER USER 'root'@'localhost' IDENTIFIED BY 'Mypassword';

 

 

 

 

相关文章:

  • 2022-01-07
  • 2021-08-12
  • 2022-01-30
  • 2022-12-23
  • 2021-11-21
  • 2021-12-16
  • 2021-12-06
猜你喜欢
  • 2021-06-17
  • 2021-10-20
  • 2021-06-03
  • 2022-12-23
  • 2022-12-23
  • 2021-04-17
  • 2022-03-04
相关资源
相似解决方案