windows平台mysql密码破解设置

 

 

windows平台下,5.7版本mysql,破解密码的两种方式:

#1 关闭mysql服务
net stop mysql

启动mysql服务 跳过权限
#2 在cmd中执行:mysqld --skip-grant-tables


另开一个cmd
#3 在cmd中执行:mysql


之前账号有密码的 不输入密码 可以进去
C:\Users\Administrator.QH-20170325TNQR>mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.41 MySQL Community Server (GPL)

Copyright (c) 2000, 2018, 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> select user;
ERROR 1054 (42S22): Unknown column 'user' in 'field list'
mysql> select user();
+--------+
| user() |
+--------+
| root@ |
+--------+
1 row in set (0.00 sec)

 

 
#4 执行如下sql:
更改之前mysql 密码
设置mysql库.user数据表 set设置密码 改为空
update mysql.user set authentication_string=password('') where user = 'root';

另外一种sql语句实现

update mysql.user set password=password("") where user="root" and host="l
ocalhost";

执行完sql语句 执行这条语句让sql语句生效
刷新数据表 刷新权限 flush privileges;

把刚才mysql服务进程 kill掉
#5 tskill mysqld #或taskkill -f /PID 7832

查看mysqld 进程
C:\Users\Administrator.QH-20170325TNQR>tasklist |findstr mysqld
mysqld.exe                    7456 Console                    1    456,020 K

kill 进程
C:\Users\Administrator.QH-20170325TNQR>taskkill -f /PID 7456
成功: 已终止 PID 为 7456 的进程。

 



#6 重新启动mysql
net start mysql
 

方式二
#1. 关闭mysql,可以用tskill mysqld将其杀死
#2. 在解压目录下,新建mysql配置文件my.ini
#3. my.ini内容,指定
[mysqld]
skip-grant-tables

#4.启动mysqld
#5.在cmd里直接输入mysql登录,然后操作
update mysql.user set authentication_string=password('') where user='root and host='localhost';

flush privileges;

#6.注释my.ini中的skip-grant-tables,然后启动myqsld,然后就可以以新密码登录了
 
 
 
posted @ 2018-10-07 18:44  minger_lcm  阅读(314)  评论(0编辑  收藏  举报