• 欢迎访问显哥博客,本网站纯属学习技术,绝无商业用途,欢迎小伙伴们共同学习!研究技术!QQ:52249909 加我QQ
  • 世界75亿人,这么小的概率,能认识你,是我一生的幸运,不妨加个QQ接触一下:52249909 加我QQ

三步搞定忘记MySQL数据库密码【显哥出品,必为精品】

MySQL lixian 3年前 (2020-12-24) 21354次浏览 0个评论 扫描二维码
文章目录[隐藏]

简单粗暴修改MySQL密码,只要三步

1.修改my.cnf文件(在mysqld下面增加三条参数)

[root@master ~]# vim /etc/my.cnf
[mysqld]
...
...
skip-host-cache
skip-name-resolve
skip-grant-tables

2.重启mysqld服务,并输入mysql直接进入数据库修改密码

[root@master ~]# systemctl restart mysql
[root@master ~]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.18-log MySQL Community Server (GPL)
#修改密码
mysql> update mysql.user set authentication_string=password('123456') where user='root';
#刷新权限
mysql> flush privileges;
mysql> quit

3.删除三条参数,重启mysql搞定

[root@master ~]# vim /etc/my.cnf
[root@master ~]# systemctl restart mysql
[root@master ~]# mysql -uroot -p123456
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.18-log MySQL Community Server (GPL)

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

本站博主 , 版权所有丨如未注明 , 均为原创
转载请注明原文链接:三步搞定忘记MySQL数据库密码【显哥出品,必为精品】
喜欢 (2)

您必须 登录 才能发表评论!