MySQL Remote Connection Loss resolution (Lost connection to MySQL server) _mysql

Source: Internet
Author: User
Tags save file

The server was very unstable recently, so the MySQL and PHP services were installed, but then there was a lot of headaches.
Remote connection MySQL is always prompted:

Copy Code code as follows:
Lost connection to MySQL server at ' reading initial communication packet ', System error:0

It is clear that this is the connection initialization phase that has lost the connection error.
Google half a day mostly say the annotation out of the configuration file Bind-address = 127.0.0.1 this sentence.
But my profile does not configure this sentence, all kinds of search did not result. Today happened to see a person on the internet to meet the same problem posted by the configuration, found that he has a more than a configuration skip-name-resolve, holding to try to change the attitude and restart the MySQL service, sure enough, remote suddenly connected, really silent.
In fact, the problem is very simple, is the MySQL configuration file is not configured for remote connections by default, only need to change the MySQL configuration file.
The specific resolution steps are as follows, hoping to help students who have the same problems:
Locate and modify the My.cnf file. Under different Linux systems, my.cnf are placed in different locations. Here is an example of Ubuntu server, and other systems should find the path to my.cnf as appropriate. Usually only stored in/etc/my.cnf or/ETC/MYSQL/MY.CNF.
First open my.cnf with vim:

Copy Code code as follows:

Vim/etc/mysql/my.cnf

To see if there is any configuration of the address of the loop, and if so, comment out the following text: (Add the # before the text)

Copy Code code as follows:

Bind-address = 127.0.0.1

Then find the parameters in the [mysqld] section, create a new line after the configuration, and add the following parameter:
Skip-name-resolve
Save file and restart MySQL:

Copy Code code as follows:
/etc/init.d/mysql restart

This will find that the problem has been solved! Remote connections are not lost.

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.