The php environment locally uses an ip address to connect to mysql. the response is fast and the localhost connection is slow.

Source: Internet
Author: User
Tags reverse dns
Today, I encountered a strange problem connecting to mysql. in the php environment, I used an ip address to connect to mysql. the response was fast and the localhost connection was slow. then Baidu sorted out some solutions, let's take a look. for a long time, in the local php environment, l... today, I encountered a strange problem connecting to mysql. in the php environment, I used an ip address to connect to mysql. the response was fast and the localhost connection was slow. then Baidu sorted out some solutions, let's take a look.

For a long time, when using localhost to connect to mysql in the local php environment, as long as the page for querying the database is accessed, the response will be slow, and some information has not been resolved.

Today, I suddenly connected it with an ip address, and the sending speed was much faster. I checked the hosts file and found that 127.0.0.1 was not resolved to localhost, the response speed is certainly slow when the parsing is not passed. it needs to search for the response every time.

The second is to modify php. mysql in The ini configuration file. default_host, and write the first parameter in mysql_connect () as a null string. this method has not been tested yet. it may be because I ignored some places ~~

Slow remote connection to MYSQL

The main cause of this problem is that the reverse DNS resolution is enabled for MYSQL installed by default. ini (in WINDOWS) or MY. add skip-name-resolve to the [mysqld] of the CNF (UNIX or LINUX) file to save.

Start -- run -- cmd -- net stop mysql -- net start mysql -- haha, success.

Path of my. ini: D: \ Program Files \ MySQL Server 5.0 \ my. ini

It turned out to be a problem with MySQL. after this operation, the host name cannot be used in the MySQL authorization table, but only ip addresses can be used.


Address:

Reprinted at will, but please attach the article address :-)

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.