Rotten mud: mysql modifies the local host connection, and mysql modifies the host

Source: Internet
Author: User

Rotten mud: mysql modifies the local host connection, and mysql modifies the host

This article was sponsored by Xiuyi linfeng and first launched in the dark world.

After the mysql database is installed, You can remotely connect to and manage the mysql database. We usually update the host records in the user table through the update command on the mysql server. As follows:

Mysql-uroot-p123456

Update user set host = '%' where user = 'root ';

Flush privileges;

/Etc/init. d/mysqld restart

After this operation, the remote host can now connect to the mysql database. However, the mysql database server cannot connect to the local mysql database, as shown below:

Why is this happening?

The reason is that the host field of the mysql database user has explicitly refused to log on locally. Now we need to modify this field to delete all unnecessary records in this field.

Stop the database first, and then start the database in mysqld_safe-skip-grant-tables & mode. This method starts the database and skips the security verification of the mysql database. As follows:

/Etc/init. d/mysqld stop

Mysqld_safe -- skip-grant-tables &

Mysql-uroot mysql

Use mysql;

Select host, user from user;

Now, we can see that there is no corresponding user for localhost. What we need to do now is to delete all the records that are not needed to be modified. Only records with host % are left.

To delete a record, use the following SQL statement:

Delete from user where host = '2017. 0.0.1 ';

Delete from user where host = 'ilanni ';

Delete from user where host = ': 1 ';

Delete from user where host = 'localhost ';

After the preceding SQL statement is completed, we restart the mysql database again. Connect to the database locally, as shown below:

We can see it clearly. The mysql database server can connect to the mysql database.

The above is a troublesome practice. The simplest practice is to delete it directly on the remote mysql management software. Because now the remote machine can log on to the mysql database, I use the Navicat Premium software again. As follows:


How to connect to MYSQL to the host

Simple. You didn't enter the password.
Enter the password you set when installing mysql.
 
Mysql Database Host connection failure reset Access denied for user '_ G' @ 'localhost' (using password: YES)

Access denied: the reason for this error is that the password used to Access the mysql database is incorrect and the user has no permission to Access the database.

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.