MySQL root password cracking Solution

Source: Internet
Author: User

The following articles mainly discuss several common methods for MySQL root password cracking. For the purpose of insurance, we copied three copies, if we have not changed the table structure in the MySQL database to be restored, just copy the user. MYD.

Then

 
 
  1. #. /etc/rc.d/init.d/MySQL stop  
  2. #. /etc/rc.d/init.d/MySQL start  
  3. #MySQL -u root -p XXXXXX  

Okay, you can log in with the MySQL password in windows 2003.

 
 
  1. MySQL>use MySQL  
  2. MySQL>update user set Password=PASSWORD(’xxxxxx’) where User=’root’;  

An error occurs, prompting that the user table has only the read permission.

I analyzed the reason. This is the only reason, because the permissions assigned to the user. * file are in windows 2003, and in windows 2003, my ls-l permission is 666.

In linux, I can see that after copying the file, the permission is changed to 600 (in fact, under normal circumstances, only the file owner here is not MySQL, the copied owner is changed to root, so there will be insufficient permissions. At this time, if you change to 666 permissions, It will be okay, of course, this is not good, there is no substance to solve the problem ), check the ls-l in/var/lib/MySQL /.

 
 
  1. #chown -R MySQL:MySQL user.*  
  2. #chmod 600 user.*  
  3. //OK,DONE  

Restart MySQL

Reconnect

 
 
  1. MySQL>use MySQL  
  2. MySQL>update user set Password=PASSWORD(’xxxxxx’) where User=’root’;  
  3. MySQL>FLUSH PRIVILEGES;  

NOTE: If MySQL is configured by default in windows, you must execute

 
 
  1. MySQL>delete from user where User=’’;  
  2. MySQL>delete from user where Host=’%’;  
  3. MySQL>FLUSH PRIVILEGES;  

Now, the MySQL root password recovery process is complete.

This method has some limitations. You must have another user table file.

There are several other methods

Other methods 1 (this is a widely spread method on the internet, MySQL Chinese Reference Manual)

1. Send the kill command to the MySQLd server to disable the MySQLd server (not kill-9). The files that store the process ID are usually located in the directory of the MySQL database.

Killall-TERM MySQLd

You must be a UNIX root user or an equivalent user on the SERVER you run to perform this operation.

2. Use the '-- skip-grant-tables' parameter to start MySQLd. In LINUX:

/Usr/bin/safe_MySQLd -- skip-grant-tables, c: \ MySQL \ bin \ MySQLd -- skip-grant-tables in windows

3. log on to the MySQLd server without a password,

> Use MySQL

> Update user set password = password ("new_pass") where user = "root ";

> Flush privileges;

. You can also do this:

MySQLadmin-h hostname-u user password 'new password''

4. Load the permission table:

MySQLadmin-h hostname flush-privileges'

Or use SQL commands

'Flush privileges'

5. killall-TERM MySQLd

6. log in with a new password

Other method 2

Directly use the hexadecimal editor to edit the user. MYD File

But here I want to explain that I found a problem when editing here. Some encrypted password strings are stored continuously, and some of the last two digits are cut, the last two digits are stored in other places. I haven't understood this yet. note that the encrypted MySQL root password string is edited, that is, you still need to have another user table file. The difference between this method and the method described above is that this method directly edits the user table file in linux, and you do not need to change the file owner and permissions.

Correct: the actual operations on Windows are as follows:

1. Disable running MySQL.

2. Open the DOS window and go to the MySQL \ bin directory.

3. Input

MySQLd-nt -- skip-grant-tables

Press enter. If no prompt is displayed, it is correct.

4. Open another DOS window (because the DOS window can no longer be moved) and go to the MySQL \ bin directory.

5. Enter MySQL and press Enter. If yes, a MySQL prompt is displayed.>

6. Connect to the permission Database

> Use MySQL;

(> It is an existing prompt. Don't forget the last Semicolon)

6. Change the password:

> Update user set password = password ("123456") where user = "root"; (do not forget the last semicolon)

7. Refresh permissions (required steps)

> Flush privileges;

8. Exit

> \ Q

9. log out of the system, log on to MySQL, and log on to MySQL with the username "root" and the new password "123456.

It is said that you can directly modify the user table file:

Close MySQL. In Windows, open MySQL \ data \ MySQL. There are three file users. frm, user. MYD, user. MYI finds a MySQL with the MySQL root Password and replaces these three files. If the user table structure has not been changed, no one will change it. MYD.

You can also directly edit user. MYD and find a hexadecimal editor. UltraEdit has this function. Close MySQL and enable user. MYD. Change the eight characters after the root user name to 565491d704013245, and the new password is 123456. Or change the hexadecimal numbers corresponding to them (one character on the left corresponds to two numbers) to 00 02 02 02 02 02 02 02 02 02. This is an empty password, the asterisk * is displayed on the right of the editor, which looks like a decimal point. Restart MySQL and enter root and your new password.
 

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.