首页 > 数据库技术 > 详细

mysql数据库忘记密码

时间:2019-07-02 12:54:31      阅读:119      评论:0      收藏:0      [点我收藏+]

新入职一家公司,没有centos7.x系统mysql数据库密码怎么办?

1、root用户登陆centos7.x系统

2、启动mysql服务

/etc/init.d/mysqld start
service mysqld start
systemctl start mysqld.service

 

3、查看mysql端口状态

lsof -i :3306
netstat -lntup |grep 3306
ss -antp |grep 3306

 

4、修改数据库配置文件,在[mysqld]中添加skip-grant-tables参数,并重启mysql服务

vim /etc/my.cnf
[mysqld]
skip-grant-tables
systemctl restart mysqld.service

 

5、使用root账户进入数据库

mysql -uroot

 

6、使用mysql数据库更新root密码

update user  set password = PASSWORD(‘newpassword’) where user = root;
flush privileges;

 

7、把刚才修改/etc/my.cnf参数注释掉,重启mysql,并使用密码登陆数据库

mysql -uroot -pnewpassword

 

mysql数据库忘记密码

原文:https://www.cnblogs.com/luowenbin/p/11119662.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!