MySQL connection error: Lost connection to MySQL server @ ' Waiting for initial communication packet '

Source: Internet
Author: User
Tags mysql login

When the remote connection to MySQL, the connection is not up, the following error occurred:
Lost connection to MySQL server @ ' Waiting for initial communication packet ', System error:0
As follows:

Cause Analysis:
MySQL turns on the DNS reverse resolution feature, so that MySQL hosts the DNS host name lookup for the connected client .
MySQL handles the client parsing process:
1) When the client of MySQL is connected, the server will proactively check the domain name of the client.
2) First find the/etc/hosts file, search the domain name and the corresponding relationship between IP.
3) If the Hosts file does not, look for DNS settings for DNS reverse resolution until the timeout connection fails.
DNS reverse resolution for MySQL:
1) MySQL receives the connection request, obtains the client's IP, in order to better match the Mysql.user in the permission record (some is defined by hostname).
2) If the MySQL server has a DNS server set up and the client IP does not have a corresponding hostname on DNS, then this process is slow and causes the connection to wait.

1) write the client's IP in the MySQL server's/etc/hosts file, give a name to the host map.
2) add skip-name-resolve in the [mysqld] area of the MY.CNF configuration file, skipping the DNS reverse resolution of MySQL connection This will improve MySQL performance well. In this case, you can only use the IP in the MySQL authorization table to connect to the MySQL service.
for the first method is obviously stupid, also not practical! The second method is strongly recommended, and the addition of the Skip-name-resolve option disables DNS resolution so that the hostname can not be used in the MySQL authorization table, only IP is used.
------------------------------------------------------------ --------------------------------------------------
In addition:
If the address of the Bind-address address binding is configured in the My.cnf file (the description can only be connected to MySQL through the address of this binding), it can be commented out.
For example:
Bind-address =
--------------------------------- -----------------------------------------------------------------------------

Several parameters of the MY.CNF configuration:
Skip-name-resolve Skip DNS Reverse parsing process
Skip-grant-tables Skip Authorization Form (solution when MySQL login password is forgotten)
Skip-networking skipping TCP/IP connections
Skip-host-cache disable host name caching; To clear the hostname cache, execute the FLUSH hosts statement or execute the mysqladmin flush-hosts command

MySQL connection error: Lost connection to MySQL server @ ' Waiting for initial communication packet '

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: 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.