The external connection to the newly installed MySQL is slow. After Ping and route, it is found that network communication is normal, and local connection on the MySQL machine is fast, therefore, network problems are basically ruled out. I have encountered such a problem before, but I don't know how to make it happen. This time I encountered such a problem, so I want to see if it is a MySQL configuration problem. After querying MySQL related documents and network searches, a configuration seems to be able to solve this problem, that is, add the following configuration parameters to the MySQL configuration file:
[Mysqld]
Skip-name-resolve
In Linux, the configuration file is/etc/My. CNF, and in windows, the configuration file is the my. ini file under the MySQL installation directory. Note that this configuration is added under [mysqld]. After you change the configuration and save the configuration, restart MySQL and remotely connect to the MySQL instance for testing. The official explanation of this parameter is as follows:
How MySQL uses DNS
When a new thread connects to mysqld, mysqld will spawn a new thread to handle the request. this thread will first check if the hostname is in the hostname cache. if not the thread will call gethostbyaddr_r () and gethostbyname_r () to resolve the hostname.
If the operating system doesn't support the above thread-safe call, the thread will lock a mutex and call gethostbyaddr () and gethostbyname () instead. note that in this case no other thread can resolve other hostnames that is not in the hostname cache
The first thread is ready.
You can disable DNS host Lookup by starting mysqld with-Skip-name-resolve. In this case you can however only use IP names in the MySQL privilege tables.
If you have a very slow DNS and have hosts, you can get more performance by either disabling DNS lookop with-Skip-name-resolve or by increasing the host_cache_size define (default: 128) and recompile mysqld.
You can disable the hostname cache with-Skip-host-Cache. You can clear the hostname cache with flush hosts or mysqladmin flush-hosts.
If you don't want to allow connections over TCP/IP, you can do this by starting mysqld with-Skip-networking.
According to the instructions in the document, if your MySQL host queries DNS slowly or if there are many client hosts, the connection will be slow, because our development machine cannot connect to the Internet, therefore, DNS resolution cannot be completed, so that you can understand why the connection is so slow. At the same time, note that after this configuration parameter is added, the host field in the MySQL authorization table cannot use the domain name but only the IP address, because this is the result of domain name resolution is forbidden.
Detailed source reference: http://www.jb51.net/article/27616.htm