TCP/IP Connection in MySQL Error 2013 (HY000): Lost connection to MySQL

Source: Internet
Author: User

The first thought was to use

1, into MySQL, create a new user root, the password is root: Format: Grant permissions on the database name. Table name to user @ Login host identified by "User password";

The code is as follows Copy Code

Grant Select,update,insert,delete on *.* to root@192.168.1.12 identified by "root"; Original data table structure mysql> use MySQL;
Database changed
Mysql> select Host,user,password from user;
+-----------+------+-------------------------------------------+
| Host | user | password |
+-----------+------+-------------------------------------------+
| localhost | Root | *81f5e21e35407d884a6cd4a731aebfb6af209e1b |
+-----------+------+-------------------------------------------+

You can see that the root user that you just created is already in the user table. The Host field indicates which hosts are logged on, their values can be IP, and host names are available.

If you are in the Linux shell command line directly to the MySQL command, can be successfully connected to MySQL, execute query statement is also more normal, but if the execution of the STOP SLAVE; The error 2013 (HY000): Lost connection to MySQL server during query problem is randomly encountered when the command occurs. If you write the operation command to the script file and then execute the script file, you will inevitably appear

Lost connection to MySQL server at ' reading initial communication packet ', System error:111

If there are any errors in remote access, it can be thought that the system has a firewall and so on, but now this strange cramp phenomenon is baffled. The last solution found is to add a startup parameter to the [MYSQLD] section inside the MY.CNF

The code is as follows Copy Code

Skip-name-resolve

Cause analysis

The so-called reverse analysis is this:

When MySQL receives the connection request, it obtains the IP of the client, in order to better match the permission record in the Mysql.user (some are defined by hostname).
If the MySQL server has a DNS server set up and the client IP does not have a corresponding hostname on DNS, the process is slow, causing the connection to wait.

After adding skip-name-resolve, I skipped a process.

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.