zhuhuibiao

如果忘记mysql的密码

修改配置文件跳过密码直接登录

在[mysqld]下面添加

vim /etc/my.cnf
skip-grant-tablses

重启mysql服务

service  mysqld  restart
/etc/rc.d/init.d/mysqld restart

登录mysql -uroot 回车

use mysql;
update user set password=password(“147258”) where user=’root’;
flush privileges;
exit;

再次修改vim /etc/my.cnf把skip-grant-tablses 删除或者添加注释注释以#开头

根据mysql数据库的版本不同,然后修改密码的命令也是不同的例如我喜欢的5.7.29这个版本的数据库就没有了 password这个字段 换成了authentication_string字段
所以命令如下所示

update user set authentication_string=password(“qwerqwer”) where user=’root’;

最后重启服务生效!!!!

分类:

技术点:

相关文章:

  • 2021-12-16
  • 2021-11-21
  • 2021-12-22
  • 2021-06-17
  • 2021-12-30
  • 2022-02-11
  • 2022-12-23
猜你喜欢
  • 2021-11-21
  • 2021-11-21
  • 2021-09-23
  • 2021-11-15
  • 2022-12-23
  • 2021-08-16
  • 2022-01-02
相关资源
相似解决方案