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