linux平台mysql密码设破解

1.先停止mysql服务

service mysqld stop

 

2.启动mysql服务 并跳过权限认证

 mysqld_safe --skip-grant-tables

3.打开另外一个终端

登录mysql

[root@mysql ~]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 1
Server version: 5.1.73 Source distribution

Copyright (c) 2000, 2013, 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> 

4.修改原来mysql的密码

update mysql.user set password=password("") where user = "root" and host = "127.0.0.1";
执行完sql语句 执行这条语句让sql语句生效
刷新数据表 刷新权限 flush privileges;

5.杀死刚才启动的mysql服务
pkill -9 mysql

6.开启mysql服务器

service mysqld start

 
原文地址:https://www.cnblogs.com/mingerlcm/p/9745482.html