mysql-破解root密码

前提:centos7、mysql5.7

1.停止mysql服务
systemctl stop mysqld.service

2.修改配置文件无密码登录
vim /etc/my.cnf
在最后加上
skip-grant-tables
保存
3.启动mysql
systemctl start mysqld.service

4.登录mysql
mysql -u root
注意这里不要加-p
5.修改密码,mysql5.7用此语法
use mysql;
update mysql.user set authentication_string=password('123456') where user='root' ;
6.回到第二部把刚加的那句删掉
保存,重启mysql就可以了

修改密码
set password=password('root@123QWE');
use mysql;
create user 'admin'@'%' identified by '123456';
grant all privileges on *.* to 'admin'@'%';

flush privileges;

posted @ 2020-07-04 18:59  苍茫宇宙  阅读(151)  评论(0编辑  收藏  举报