lichunpeng

mysql5.7.25 忘记密码后更改root密码

 
1.修改my.cnf
]# vi /etc/my.cnf
#在[mysqld]中添加一行代码:
skip-grant-tables
2.重启mysql
]# systemctl restart mysqld
3.1进入mysql(5.7以后)修改密码
]# mysql
mysql> use mysql;
mysql> update user set authentication_string = password(\'要更改的密码\') where user=\'root\';
mysql> flush privileges;
mysql> quit;
3.2进入mysql(5.7以前)修改密码
]# mysql
mysql> use mysql;
mysql>update user set password = password(\'要更改的密码\') where user=\'root\';
mysql> flush privileges;
mysql> quit;
4.重启mysql
]# systemctl restart mysqld
]# mysql -uroot -p
输入更改后的密码
5.注释/etc/my.cnf文件中的
skip-grant-tables

 

分类:

技术点:

相关文章:

  • 2021-06-04
  • 2021-11-07
  • 2022-02-10
  • 2021-08-29
  • 2021-04-02
  • 2021-06-19
猜你喜欢
  • 2021-11-15
  • 2021-07-18
  • 2021-06-11
  • 2021-09-05
  • 2021-09-25
  • 2021-11-24
  • 2021-04-03
相关资源
相似解决方案