MySQL database root password lost hack method

Source: Internet
Author: User
Tags reserved

MysqlPassword loss hack method

1th ChapterSingle Instance crack method1.1StopMysqlService
[[email protected] ~]#/etc/init.d/mysqld stopshutting down MySQL. success!
1.2 RestartMysqlStart

Start directly with the Mysqld_safe command and add parameter --skip-grant-tables, skip permission authentication table

[[email protected] ~]# mysqld_safe--skip-grant-tables &[1] 5985[[email protected] ~]# 180125 05:17:49 mysqld_safe Log Ging to '/opt/mysql/data/mysql01.err '. 180125 05:17:49 Mysqld_safe starting mysqld daemon with databases from/opt/mysql/d Ata
1.3Direct login without passwordMysql

After step 2 starts successfully, you can log in to the database without a password:

[Email protected] ~]# mysql-urootwelcome to the MySQL monitor. Commands End With; or \g.your MySQL connection ID is 1Server version:5.5.55 mysql Community Server (GPL) Copyright (c) #, Oracle an d/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names trademarks of their respectiveowners. Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.mysql>
1.4ModifyRootPassword

use UPDATE in mysql command to Change Password

mysql> Update Mysql.user SET password=password ("123456") WHERE user= ' root ' and host= ' localhost ' Query OK, 1 row affected (0.00 sec) Rows matched:1 changed:1 warnings:0

Update : Modify Password Command

Mysql.user : databases and tables that store user information

SET: Set Password Parameters

Password=password ("123456") : set a new password, where The purpose of PASSWORD is to encrypt "123456" , which must be added

WHERE user= ' root ' and host= ' localhost ' : Locate the user who needs to change the password

1.5Refresh User rights:
mysql> flush Privileges; Query OK, 0 rows Affected (0.00 sec)
1.6exit and restart the database
Kill Pid[[email Protected] ~]#/etc/init.d/mysqld startstarting MySQL. success!

Modification Done!

[Email protected] ~]# mysql-uroot-p123456
2nd Chaptermulti-Instance crack method

Multi-instance cracking is similar to an example, except that there are more parameters to be answered.

2.1StopMysqlService

First , the process number of the MYSQLD service is found through Ps-ef, and then the process is killed by the kill command.

[[email protected] support-files]# ps -ef |grep  3308 | grep -v grep root      59695       1  0 04:15 pts/1    00:00:00 /bin/sh  /opt/mysql/bin/mysqld_safe --defaults-file=/data/3308/my.cnfmysql      60419  59695  0 04:15 pts/1    00:00:07 /opt/ mysql-5.5.32/bin/mysqld --defaults-file=/data/3308/my.cnf --basedir=/opt/mysql --datadir=/data/ 3308/data --plugin-dir=/opt/mysql/lib/plugin --user=mysql --log-error=/data/3308/mysql_3308.err  --open-files-limit=8192 --pid-file=/data/3308/mysqld.pid --socket=/data/3308/mysql.sock - -port=3308[[email protected] support-files]# kill 60419 


Note: The kill-9 parameter cannot be used here , otherwise it will cause serious consequences.

2.2UseMysqld_safeStart
[Email protected] 3308]# mysqld_safe--defaults-file=/data/3308/my.cnf--skil-grant-table &[1] 61039[[email Protected] 3308]# 180127 07:11:02 mysqld_safe Logging to '/var/log/mysqld.log '. 180127 07:11:02 mysqld_safe Starting MySQL D daemon with databases from/var/lib/mysql180127 07:11:02 mysqld_safe mysqld from PID File/var/run/mysqld/mysqld.pid end Ed [1]+ Done Mysqld_safe--default-file=/data/3308/my.cnf--skil-grant-tables

Note: The parameter --skil-grant-tables needs to be added at the end of the command.

2.3Login database without password

Multi-instance login MySQL database requires the sock file to be specified:

[Email protected] 3308]# mysql-uroot-p-s/data/3308/mysql.sockenter password:welcome to the MySQL monitor. Commands End With; or \g.your MySQL connection ID is 1Server version:5.5.32 Source distribution Copyright (c) +, Oracle and/or its Affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names trademarks of their respectiveowners. Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement. Mysql>
2.4 Reset Password
mysql> Update Mysql.user SET password=password ("123456") where user= ' root ' and host= ' localhost '; Query OK, 1 row Affected (0.00 sec) Rows matched:1 changed:1 warnings:0 mysql>
2.5Refresh user Permissions
mysql> flush Privileges; Query OK, 0 rows Affected (0.00 sec)
2.6exit and restart the database
[[email protected] 3308]# kill 61955[[email protected] 3308]# 180127 07:19:08 mysqld_safe mysqld from PID file/data/3308/ Mysqld.pid ended [1]+ done Mysqld_safe--defaults-file=/data/3308/my.cnf--skip-grant-table[[email Pro Tected] 3308]#/data/3308/mysql startstarting MySQL ...
2.7Re-login
[Email protected] 3308]# mysql-uroot-p123456-s/data/3308/mysql.sock Welcome to the MySQL monitor. Commands End With; or \g.your MySQL connection ID is 1Server version:5.5.32 Source distribution Copyright (c) +, Oracle and/or its Affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names trademarks of their respectiveowners. Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement. Mysql>

Complete!!


MySQL database root password lost hack method

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.