解决远程连接mysql很慢的方法(mysql_connect 打开连接慢)_MySQL
[mysqld]
skip-name-resolve
在linux下配置文件是/etc/my.cnf,在windows下配置文件是mysql安装目录下的my.ini文件。注意该配置是加在 [mysqld]下面,在更改配置并保存后,然后重启mysql并远程连接测试,一切恢复如初。该参数的官方解释信息如下:
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 calls, 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 until the first thread is ready.
You can disable DNS host lookup by starting mysqld with
推荐阅读
-
NaviCat连接“不支持远程连接的MySql数据库”解决方案_MySQL
-
php 环境本地用ip连接mysql响应快,用localhost连接慢的解决
-
CentOS下php使用127.0.0.1不能连接mysql的解决方法_MySQL
-
CentOS下php使用127.0.0.1不能连接mysql的解决方法
-
MySQL出现SQL Error (2013)连接错误的解决方法
-
C3P0连接池+MySQL的配置及wait_timeout问题的解决方法
-
MYSQL不能从远程连接的一个解决方法(s not allowed to connect to this MySQL server)
-
NaviCat连接时提示"不支持远程连接的MySql数据库"解决方法
-
解决远程连接mysql很慢的方法(mysql_connect 打开连接慢)
-
java连接mysql数据库乱码的解决方法