Slime: MySQL modifies the local host connection

Source: Internet
Author: User

this article starting at Slime Line the world .

After the MySQL database is installed, in order to be able to remotely connect to manage MySQL database. We typically update the host record in the user table on the MySQL server via the update command. As follows:

mysql-uroot-p123456

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

FLUSH privileges;

/etc/init.d/mysqld restart

650) this.width=650; "title=" clip_image001 "style=" border-right-width:0px;background-image:none; border-bottom-width:0px;padding-top:0px;padding-left:0px;margin:0px;padding-right:0px;border-top-width:0px; " Border= "0" alt= "clip_image001" src= "Http://img1.51cto.com/attachment/201411/5/526870_1415154077rL8u.png" width= " 564 "height=" 391 "/>

After this operation, it is found that the remote host can now connect to the MySQL database. However, on the MySQL database server, you cannot connect to the local MySQL database, as follows:

650) this.width=650; "title=" clip_image002 "style=" border-right-width:0px;background-image:none; border-bottom-width:0px;padding-top:0px;padding-left:0px;margin:0px;padding-right:0px;border-top-width:0px; " Border= "0" alt= "clip_image002" src= "Http://img1.51cto.com/attachment/201411/5/526870_1415154080Sfo0.png" width= " 603 "height=" 193 "/>

650) this.width=650; "title=" clip_image003 "style=" border-right-width:0px;background-image:none; border-bottom-width:0px;padding-top:0px;padding-left:0px;margin:0px;padding-right:0px;border-top-width:0px; " Border= "0" alt= "clip_image003" src= "Http://img1.51cto.com/attachment/201411/5/526870_1415154081ELKy.png" width= " 576 "height="/>

Why is this happening?

Because the local login has been explicitly denied in the user's host field of the MySQL database. We now need to modify this field to remove all related records that are not needed in the field.

Stop the database first, and then start the database using the Mysqld_safe–skip-grant-tables & method. This method starts the database and skips the security validation 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;

650) this.width=650; "title=" clip_image004 "style=" border-right-width:0px;background-image:none; border-bottom-width:0px;padding-top:0px;padding-left:0px;margin:0px;padding-right:0px;border-top-width:0px; " Border= "0" alt= "clip_image004" src= "Http://img1.51cto.com/attachment/201411/5/526870_1415154081xhQq.png" width= " 458 "height=" 560 "/>

Through, we can see that there is no corresponding user on localhost. What we need to do now is to change all the deletions that are not needed in the record. Leave only the record of the host as%.

To delete a record, you need to use the following SQL statement:

Delete from user where host= ' 127.0.0.1 ';

Delete from user where host= ' Ilanni ';

Delete from user where host= ':: 1 ';

Delete from user where host= ' localhost ';

650) this.width=650; "title=" clip_image005 "style=" border-right-width:0px;background-image:none; border-bottom-width:0px;padding-top:0px;padding-left:0px;margin:0px;padding-right:0px;border-top-width:0px; " Border= "0" alt= "clip_image005" src= "Http://img1.51cto.com/attachment/201411/5/526870_1415154082p4a2.png" width= " 349 "height=" 564 "/>

Once the above SQL statements have been completed, we restart the MySQL database again. Then the local connection database looks like this:

650) this.width=650; "title=" clip_image006 "style=" border-right-width:0px;background-image:none; border-bottom-width:0px;padding-top:0px;padding-left:0px;margin:0px;padding-right:0px;border-top-width:0px; " Border= "0" alt= "clip_image006" src= "Http://img1.51cto.com/attachment/201411/5/526870_1415154082uddQ.png" width= " 551 "height=" 309 "/>

Through, we can obviously see. The MySQL database server is already connected to the MySQL database.

The above is a cumbersome approach, the simplest way is to delete the remote MySQL management software directly. Because the remote machine is now able to log on to the MySQL database, again I use the navicat premium software. As follows:

650) this.width=650; "title=" clip_image007 "style=" border-right-width:0px;background-image:none; border-bottom-width:0px;padding-top:0px;padding-left:0px;margin:0px;padding-right:0px;border-top-width:0px; " Border= "0" alt= "clip_image007" src= "Http://img1.51cto.com/attachment/201411/5/526870_1415154082nfGv.png" width= " 375 "height=" 522 "/>

650) this.width=650; "title=" clip_image008 "style=" border-right-width:0px;background-image:none; border-bottom-width:0px;padding-top:0px;padding-left:0px;padding-right:0px;border-top-width:0px; "border=" 0 "alt = "clip_image008" src= "Http://img1.51cto.com/attachment/201411/5/526870_1415154083LKWV.png" width= "438" height= " 533 "/>

This article is from the "Slime Row World" blog, please be sure to keep this source http://ilanni.blog.51cto.com/526870/1571973

Slime: MySQL modifies the local host connection

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.