1. 先杀掉mysqld的进程:

service mysql stop 

2. 使用skip-grant-tables这个选项启动MySQL:

vi /etc/my.cnf

在mysqld 下添加 

skip-grant-tables

3. 登录修改密码:

service mysql start

mysql -uroot -p

SET PASSWORD FOR 'root'@'%' = OLD_PASSWORD('123456');

--update user set password=PASSWORD("123456") where user='root'

flush privileges

4. 关掉MySQL

service mysql stop 

5.还原配置文件

vi /etc/my.cnf

注掉 skip-grant-tables

6.启动mysql 服务

service mysql start

 

相关文章:

  • 2022-01-22
  • 2021-10-13
猜你喜欢
  • 2021-07-29
  • 2021-09-12
  • 2021-12-25
  • 2021-06-10
  • 2021-12-27
  • 2021-12-27
  • 2021-09-21
相关资源
相似解决方案