linux上的mysql忘记密码

时间:2020-12-23 11:52:10   收藏:0   阅读:0

1、查看mysql服务是否起来

技术图片

 

 

 

2、通过修改mysql的配置文件/etc/my.conf,跳过验证,:wq保存退出

skip-grant-tables

技术图片

 

 

3.重启数据库

运行命令:systemctl restart mysqld

 

 4.进入到mysql数据库

运行命令:mysql -u root 

 

技术图片

 

 

5、修改密码

运行语句:use mysql;
继续运行语句:update mysql.user set authentication_string=password(root_password) where user=root;    
root_password替换成你想要的密码,符合密码复杂程度
最后运行语句:flush privileges;

 

7、将刚才添加的语句从/etc/my.cnf删除

重启mysql服务,即可

 

参考:https://www.cnblogs.com/black-fact/p/11613361.html

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!