Several Methods to crack the mysql root Password

Source: Internet
Author: User

Comments: Several methods to crack the mysql root PASSWORD circulating on the Internet: Method 1: Use phpmyadmin, which is the simplest. Modify the user table of the mysql database, but do not forget to use the PASSWORD function. Method 2: Use mysqladmin, which is a special case stated above. Mysqladmin-u root-p password mypasswd input several methods circulating on the Internet to crack the mysql root password: method 1
Use phpmyadmin, which is the simplest. Modify the user table of the mysql database, but do not forget to use the PASSWORD function. Method 2
Use mysqladmin, which is a special case stated above.
Mysqladmin-u root-p password mypasswd
After entering this command, you need to enter the original root password, and then the root password will be changed to mypasswd.
Change the root in the command to your username, and you can change your password.
Of course, if your mysqladmin cannot connect to mysql server, or you cannot execute mysqladmin, this method is invalid, and mysqladmin cannot clear the password. The following methods are used at the mysql prompt and must have the root permission of mysql:
Method 3
Mysql> Insert INTO mysql. user (Host, User, Password)
VALUES ('%', 'Jeffrey ', PASSWORD ('biscuit '));
Mysql> FLUSH PRIVILEGES
Specifically, this is adding a user with the username jeffrey and password biscuit.
I wrote this example in mysql Chinese reference manual.
Be sure to use the PASSWORD function, and then use flush privileges. Method 4
Similar to method Sany, but the REPLACE statement is used.
Mysql> replace into mysql. user (Host, User, Password)
VALUES ('%', 'Jeffrey ', PASSWORD ('biscuit '));
Mysql> flush privileges Method 5
Use the set password statement,
Mysql> set password for jeffrey @ "%" = PASSWORD ('biscuit ');
You must use the PASSWORD () function, but do not need to use flush privileges.
Method 6
Use the GRANT... identified by statement
Mysql> grant usage on *. * TO jeffrey @ "%" identified by 'biscuit ';
Here, the PASSWORD () function is unnecessary and does not need to be flush privileges.
Note: PASSWORD () [not] implements PASSWORD encryption in the same way as Unix PASSWORD encryption.
How to fix MySQL password loss
If MySQL is running, killall-TERM mysqld is first killed.
Start MySQL: bin/safe_mysqld -- skip-grant-tables &
You can access MySQL without a password.
Then
> Use mysql
> Update user set password = password ("new_pass") where user = "root ";
> Flush privileges;
Kill MySQL again and start MySQL in a normal way.
Clear mysql password
Windows:
1. log on to the system as a system administrator.
2. Stop MySQL services.
3. Go to the Command window and enter the MySQL installation directory. For example, if my installation directory is c: \ mysql, go to C: \ mysql \ bin.
4. Skip the permission check and start MySQL,
C: \ mysql \ bin> mysqld-nt -- skip-grant-tables
5. open a new window, go to the c: \ mysql \ bin directory, and set the new root password.
C: \ mysql \ bin> mysqladmin-u root flush-privileges password "newpassword"
C: \ mysql \ bin> mysqladmin-u root-p shutdown
Replace newpassword with the root password you want to use. The second command will prompt you to enter a new password and repeat the password entered by the first command.
6. Stop MySQL Server and start Mysql in Normal Mode
7. You can use a new password to link to Mysql. Unix & Linux:
1. log on to the system using root or a user running mysqld;
2. Use the kill command to end the mysqld process;
3. Use the -- skip-grant-tables parameter to start MySQL Server
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 password change
To modify mysql, run the following command on the mysql command line:
Mysql-u root mysql
Mysql> Update user SET password = PASSWORD ("new password") Where user = 'name ';
Mysql> flush privileges;
Mysql> QUIT teaches you how to restore the password of the MySQL database because the MySQL password is stored in the user table of the mysql database, therefore, you only need to copy and overwrite the user table in MySQL under windows 2003. In c: \ mysql \ data \ mysql \ (linux, there are three user table related files in the/var/lib/mysql/) directory. frm, user. MYD, user. MYI user. frm // user Table Style File user. MYD // user table data file user. MYI // user: The index file of the table is safe. All three are copied. However, if the table structure has not been changed on the MySQL to be restored, you only need to copy the user. MYD.
#./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 the mysql password in windows 2003.
Mysql> use mysql
Mysql> update user set Password = PASSWORD ('xxxxxx') where User = 'root ';
At this time, an error occurs. The system prompts that the user table has only the read permission. * The File Permission is assigned in windows 2003. In windows 2003, when ls-l is used, 666 is used in linux, after the copy, the permission is changed to 600 (in fact, under normal circumstances, only the file owner here is not mysql, and the owner after the copy is changed to root, so there will be insufficient permissions. At this time, if you change the permission to 666, it will be okay. Of course, this is not good and there is no solution to the problem ), check the ls-l in/var/lib/mysql /.
# Chown-R mysql: mysql user .*
# Chmod 600 user .*
// OK, DONE restarts MYSQL and reconnects
Mysql> use mysql
Mysql> update user set Password = PASSWORD ('xxxxxx') where User = 'root ';
Mysql> flush privileges;
NOTE: If mysql is configured by default in windows, you must execute
Mysql> delete from user where User = '';
Mysql> delete from user where Host = '% ';
Mysql> flush privileges;
Now, the password recovery process completes this method, which is a little limited, you must also have another user table file. There are also several other methods. (This is a widely spread method on the Internet, from the mysql Chinese Reference Manual.) 1. send the kill command to the mysqld server to turn off the mysqld server (not kill-9). files that store process IDs 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. use the new password to log on to another method 2. Use the hexadecimal editor to edit the user. MYD file, but I want to explain it here. I found a problem during 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 password string is edited, that is, you still need to have another user table file. The difference between this method and the method I introduced above is that this method directly edits the user table file in linux without modifying the file owner and permissions: my actual operations in 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 the connection succeeds, the MySQL prompt> 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, open Mysql \ data \ mysql in Windows, there are three files user. frm, user. MYD, user. MYI finds a MySQL with a password and replaces these three files. If the user table structure has not been changed, no one will change it. Replace the user. 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.

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.