modified to crack MySQL password method Daquan

Source: Internet
Author: User
Tags command line manual flush mysql in mysql command line mysql database

Method One

Using phpMyAdmin, this is the easiest, to modify the MySQL library's user table, but don't forget to use the password function.

Method Two

Using Mysqladmin, this is a special case of the previous declaration.

Mysqladmin-u root-p Password mypasswd

After entering this command, you need to enter the original password for root, and then the root password will be changed to MYPASSWD.

Change the command root to your username, and you can change your password.

Of course, if your mysqladmin is not connected to MySQL server, or you have no way to execute mysqladmin, then this method is invalid, and mysqladmin cannot empty the password.

The following methods are used at the MySQL prompt and must have the root permissions of MySQL:

Method Three

Mysql> Insert into Mysql.user (Host,user,password)

VALUES (%,jeffrey,password (biscuit));

Mysql> FLUSH Privileges

To be exact, this is adding a user, the username is Jeffrey, and the password is biscuit. In the MySQL Chinese reference manual for this example, note that you want to use the password function, and then use the flush privileges.

Method Four

And method Three, just use the Replace statement

Mysql> REPLACE into Mysql.user (Host,user,password)

VALUES (%,jeffrey,password (biscuit));

Mysql> FLUSH Privileges

Method Five

Using the Set Password statement

Mysql> SET PASSWORD for jeffrey@ "%" = PASSWORD (biscuit);

You must also use the password () function, but you do not need to use flush privileges.

Method Six

Use Grant ... Identified by statement

Mysql> GRANT USAGE on *.* to jeffrey@ "%" identified by biscuit;

Here the password () function is unnecessary and does not require the use of flush privileges.

Note: PASSWORD () [is not] the password encryption is performed in the same way as the UNIX password encryption.

MySQL Forgot Password Solution

If MySQL is running, first kill:

Killall-term mysqld

Start MySQL:

Bin/safe_mysqld--skip-grant-tables &

You can enter MySQL without the need for a password.

Then it's

>use MySQL

>update User Set Password=password ("New_pass") where user= "root";

>flush privileges;

Re-kill MySQL, the normal way to start MySQL.

MySQL Password empty

Windows

1. Login system with system administrator;

2. Stop the MySQL service;

3. Enter the command window, and then enter the MySQL installation directory, such as my installation directory is c:mysql, into the C:mysqlin;

4. Skip permission check to start MySQL

C:mysqlin>mysqld-nt--skip-grant-tables

5. Reopen a window, enter the C:mysqlin directory, set the new password for root

C:mysqlin>mysqladmin-u root flush-privileges password "NewPassword"

C:mysqlin>mysqladmin-u root-p shutdown

Replace the newpassword with the root password you want to use, and the second command will prompt you to enter a new password and repeat the password entered in the first command;

6. Stop MySQL Server, start MySQL in normal mode;

7. You can link to MySQL with a new password.

Unix&linux

1. User login system with root or running mysqld;

2. Use KILL command to end the process of mysqld;

3. Start MySQL Server with the--skip-grant-tables parameter

Shell>mysqld_safe--skip-grant-tables &

4. Set a new password for root@localhost

Shell>mysqladmin-u root flush-privileges password "NewPassword"

5. Restart MySQL Server.

MySQL Modify password

MySQL modifications can be performed on the MySQL command line as follows:

Mysql-u Root MySQL

mysql> Update user SET Password=password ("New password") Where user=name;

mysql> FLUSH privileges;

Mysql> QUIT

Teach you how to restore the MySQL database password

Because the MySQL password is stored in the user table in database MySQL, just copy the user table from my Windows 2003 MySQL to cover it.

In C:mysqldatamysql (Linux is generally in/var/lib/mysql/mysql/) directory has three user table related files user.frm, user. MyD, user. Myi

User.frm//user Table Style file

User. MyD//user Table Data file

User. Myi//user Table Index file

To be on the safe side, three copies are copied, but in fact if you have not changed the table structure on the MySQL that you want to restore, just copy user. MyD on the line.

And then

#. /etc/rc.d/init.d/mysql stop

#. /etc/rc.d/init.d/mysql start

#mysql-U root-p XXXXXX

Okay, you can log in with Windows 2003 MySQL password.

Mysql>use MySQL

Mysql>update user Set Password=password (xxxxxx) where user=root;

This can be an error, prompting the user table with Read permission only.

I analyzed the reason, just like this, because the user.* file's permission assignment is under Windows 2003, under Windows 2003 I ls-l see the permission is 666.

When I look at Linux, cuff after the permission to become 600 (in fact, the normal situation 600 on the line, but here is the file is not MySQL, the owner of the copy came to root, so there will be insufficient permissions, this time if you change to a permission of 666 can, of course, this is not good, Did not solve the problem of the substance), under the/var/lib/mysql/mysql/Ls-l looked at

#chown-R Mysql:mysql user.*

#chmod user.*

Ok,done

Reset MySQL, reconnect

Mysql>use MySQL

Mysql>update user Set Password=password (xxxxxx) where user=root;

Mysql>flush privileges;

One thing to note: If you have windows under MySQL if it is the default configuration, note that you have to perform

Mysql>delete from user where user=;

Mysql>delete from user where host=%;

Mysql>flush privileges;

Okay, here's the process of restoring the password. This approach is a bit of a limitation, and you have to have another user table file. There are several other ways.

Other methods one (this is a popular online method, MySQL Chinese reference manual)

1. Send Kill command to MYSQLD server to turn off MYSQLD server (not kill-9), and the file that holds the process ID is usually in the directory where the MySQL database resides.

Killall-term mysqld

You must be a UNIX root user or an equivalent user on the server you are running to perform this operation.

2. Use the '--skip-grant-tables parameter to start the mysqld. Linux under:

/usr/bin/safe_mysqld--skip-grant-tables, Windows C:mysqlinmysqld

--skip-grant-tables

3. Then login to 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. Loading permission table:

mysqladmin-h hostname flush-privileges

or use SQL commands

FLUSH Privileges

5.

Killall-term mysqld

6. Log in with the new password.

Other method Two

Edit user directly with the hexadecimal editor. myd files.

But here I want to make it clear that I found a problem when I edited it, some of the encrypted cipher strings were stored continuously, some of the last two bits were cut, and the two bits were stored in the back. I haven't figured it out yet. It's also important to note that the encrypted cipher string is edited, which means you still need to have another user table file. The difference between this approach and the one I described above is that this method directly edits the user table file under Linux without having to change the file owner and permissions.

Fix it: My actual operation under Windows is as follows

1. Close the running MySQL;

2. Open the DOS window and go to the Mysqlin directory;

3. Input

Mysqld-nt--skip-grant-tables

Enter. If you don't get a hint, that's it.

4. Open a DOS window again (because the DOS window is already unable to move), go to the Mysqlin directory.

5. Enter MySQL return, if successful, will appear MySQL prompt >

6. Connection Rights Database

>use MySQL;

(> is the original prompt, don't forget the last semicolon)

6. Change Password:

> Update user Set Password=password ("123456") where user= "root";

(Don't forget the last semicolon)

7. Refresh permissions (required steps)

>flush privileges;

8. Exit

> Q

9. Logout system, re-enter, open MySQL, use user name root and just set the new password 123456 login.

It is said that you can use the method of directly modifying the user table file:

Close Mysql,windows Open Mysqldatamysql, there are three files User.frm,user. Myd,user. Myi find a password to know the MySQL, replace the corresponding three files, if the user table structure has not changed, generally no one to change, replace user. MyD is OK.

You can also edit the user directly. MyD, find a hexadecimal editor, UltraEdit has this function. Turn off MySQL and open user. MyD. Change the eight characters after user name root to 565491d704013245, and the new password is 123456. or the hexadecimal numbers corresponding to them

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.