mysql password hack.

Source: Internet
Author: User
Tags mysql version administrator password

It is more accurate than MySQL password cracking, because in most cases we just forget the password, if it is normal users can also let the administrator reset the password or reassign a user, but here we do not consider the ordinary user, What if the administrator password is forgotten? It is impossible to get back, although the user table in MySQL records the information of each users, but ordinary users generally do not have permission to operate, and where the password is generated through one-way encryption. So the easiest way to forget about the admin password is to reset it.

Here are two scenarios for analyzing Linux under and under Windows

Under Linux operating system:

MySQL version 5.5

1. Modify the MySQL configuration file

Vim/etc/my.cnf

Find and MySQL server configuration related section [mysqld], add skip-grant-tables at the end, as shown below

Socket =/tmp/mysql.sock

Myisam_sort_buffer_size = 8M

Skip-grant-tables//Set MySQL server to start skip permission table

Save and exit

2. Restart the MySQL server

./usr/local/mysql/bin/mysqld_safe

Note that this time the MySQL permissions table has been lost, in order to prevent attacks from outside, it is best to break the network operation.

3. Log in and modify the password of the administrator root user

Re-open a terminal, if the previous step is placed in the background execution, you can also be executed under the same terminal

./usr/local/mysql/bin/mysql is shown below

[Email protected] bin]#/mysql-u root-p

Enter Password:
Welcome to the MySQL Monitor. Commands End With; or \g.
Your MySQL Connection ID is 3
Server Version:5.5.23-log Source Distribution

Copyright (c), +, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of the Oracle Corporation and/or its

Affiliates. Other names trademarks of their respective
Owners.

Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.

mysql> show databases;

+--------------------+
| Database |
+--------------------+
| Information_schema |
| MySQL |
| Performance_schema |

At this point, you don't need to enter the administrator root password.

Select MySQL Library

mysql> use MySQL;

Change root password

mysql> Update user set Password=password (' 123456 ') where user= ' root ' and host= ' 127.0.0.1 ';

Query OK, 1 row affected (0.11 sec)
Rows matched:1 changed:1 warnings:0

Refresh the permissions list so that the next boot of the server can take effect

mysql> flush Privileges;
Query OK, 0 rows affected (0.01 sec)

4. Modify the MySQL configuration file

Vim/etc/my.cnf

Remove the skip-grant-tables from step one in the paragraph in [mysqld],
Save and Exit VI.

5. Restart the MySQL server to

./usr/local/mysql/bin/mysqld_safe

Use the password you just reset to log in to MySQL

In the Windows environment

1. Turn on DOS switch to the MySQL installation directory under the Bin folder

2. Enter Mysqld--skip-grant-table return

Take care not to quit

3. Then open a DOS window to switch to the MySQL installed directory under the Bin folder

4. Enter MySQL return

5. Select MySQL Library, use MySQL

6. Reset the root password

Update user set Password=password (' NewPassword ') where user= ' root '

7. Refresh the Permissions table

Flush Privileges

8. Exit two terminals and log in again

mysql password hack.

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.