first of all, thanks in this fault Amin to my selfless help, thank you very much! Amin Linux Forum:http://www.apelearn.com/study_v2/
Problem Description:
Public Security Department Scan to the database security risks, the database does not need to be authenticated to directly connect remotely.
Process steps:
①: See the--skip-grant-table #怀疑是之前的管理员忘记了root密码才这样弄的 is turned on in the discovery MY.CF.
②: Use the following command to change the database password and write it. If you know the root password can be omitted, because I do not have the root password, so I changed a bit.
UPDATE user SET Password = Password (' 123456 ') where user = ' root ';
FLUSH privileges;
③: Stop the database, comment out the--skip-grant-table, and start the database.
④: Use the following command to log into the database, but error.
mysql-uroot-p123456
ERROR 1045 (28000): Access denied for user ' root ' @ ' localhost ' (using Password:yes)
⑤: Using Mysql-uroot can enter the database, but only see the test this data, I am in addition--skip-grant-table all the data to see.
+-----------------------+
| Database |
+-----------------------+
| Information_schema |
| ACTIVEMQ |
| Bjsdzx_real |
| EMCC |
| Estonerhr_cms |
| Estonerhr_oa |
| Logistic |
| Logistic_shortmessage |
| MySQL |
| Performance_schema |
| Test |
+-----------------------+
Note: When adding--skip-grant-table, use the command select Host, user, password from Mysql.user to obtain the following information.
+-----------------------+--------+-------------------------------------------+
| Host | user | password |
+-----------------------+--------+-------------------------------------------+
| % | Root | *6bb4837eb74329105ee4568dda7dc67ed2ca2ad9 |
| Localhost.localdomain | Root | *6bb4837eb74329105ee4568dda7dc67ed2ca2ad9 |
| 127.0.0.1 | Root | *6bb4837eb74329105ee4568dda7dc67ed2ca2ad9 |
| :: 1 | Root | *6bb4837eb74329105ee4568dda7dc67ed2ca2ad9 |
| localhost | | |
| Localhost.localdomain | | |
| % | Server | *866d5a029d62ec05acc4584ce50f1cd2f50e0e82 |
+-----------------------+--------+-------------------------------------------+
7 Rows in Set (0.00 sec)
resolution steps: Ming elder brother to my answer is, in Mysql.user table two empty user, delete after change password then authorize on can.
① start the database with the--skip-grant-table parameter turned on and use the following command to delete the empty users in the Mysql.user table.
Mysql> Delete from mysql.user where user= ';
Query OK, 2 rows Affected (0.00 sec)
② use the following command to query the contents of Mysql.user, found that the empty user has been deleted.
Mysql> Select Host, user, password from user\g;
+-----------------------+--------+-------------------------------------------+
| Host | user | password |
+-----------------------+--------+-------------------------------------------+
| % | Root | *6bb4837eb74329105ee4568dda7dc67ed2ca2ad9 |
| Localhost.localdomain | Root | *6bb4837eb74329105ee4568dda7dc67ed2ca2ad9 |
| 127.0.0.1 | Root | *6bb4837eb74329105ee4568dda7dc67ed2ca2ad9 |
| :: 1 | Root | *6bb4837eb74329105ee4568dda7dc67ed2ca2ad9 |
| % | Server | *866d5a029d62ec05acc4584ce50f1cd2f50e0e82 |
+-----------------------+--------+-------------------------------------------+
5 rows in Set (0.00 sec)
③ use the following command to change the root password to 123456
mysql> UPDATE mysql.user SET Password = Password (' 123456 ') where user = ' root ';
④ use the following command to authorize root user rights
Mysql> Grant All on * * to ' root ' @ '% ' identified by ' 123456 ';
⑤ use the following command to write memory information to the file
mysql> flush Privileges;
⑥ Log out and comment out the--skip-grant-table in the my.cf file
⑦ Restart the MySQL service.
Verify:
① use the following command to enter MySQL
Mysql>mysql-uroot-p 123456;
② use the following command to query all the databases, the discovery can be seen
mysql> show databases;
+-----------------------+
| Database |
+-----------------------+
| Information_schema |
| ACTIVEMQ |
| Bjsdzx_real |
| EMCC |
| Estonerhr_cms |
| Estonerhr_oa |
| Logistic |
| Logistic_shortmessage |
| MySQL |
| Performance_schema |
| Test |
+-----------------------+
Rows in Set (0.00 sec)
============================= to the end, the fault processing is complete ===================
This article is from the "Wang Ke's Technical blog" blog, please be sure to keep this source http://wangxiaoke.blog.51cto.com/5150707/1685924
MySQL does not require authentication to remotely connect to a fault