一、缘由

  由于各种原因,我们会忘记mysql的root密码。

 

二、解决办法

  

方法一:skip-grant-tables方式启动

1、停止mysql服 务

service mysqld stop

2、以跳过授权方式启动mysql

mysqld_safe --skip-grant-tables &

3、登陆mysql并更新root密码

mysql –uroot –p

use mysql;

update user set password=PASSWORD(‘new_password’) where user=’root’;

flush privileges;

4、启动mysql

service mysqld start

 

方法二:更改配置文件

1、在my.cnf [mysqld] 配置部分里添加”skip-grant-tables”

2、重启mysql服务器 service mysqld restart

3、登入mysql并重置密码

use mysql;

update user set password=PASSWORD(“new_password”) where user=”root”;

flush privileges;

4、删除之前添加的配置     “skip-grant-tables”

5、重启mysql服务 service mysqld restart

 

相关文章:

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