时间:2021-05-23
最近在Linux服务器上安装MySql5后,本地使用客户端连MySql速度超慢,本地程序连接也超慢。
解决方法:在配置文件my.cnf的[mysqld]下加入skip-name-resolve。
原因是默认安装的MySql开启了DNS的反向解析。如果禁用的话就不能在MySQL的授权表中使用主机名了而只能用ip格式。
附: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 --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 many hosts, you can get more performance by either disabling DNS lookup 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.
或者host中添加
192.168.1.21 N-21
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
备注1:解决连接MySQL数据库很慢的问题vim/etc/my.cnf添加内容:skip-name-resolve,重启数据库。备注2:(密码带!或其他特殊符合
1.问题:mysqlDNS反解:skip-name-resolve错误日志有类似警告:1.12011916:26:04[Warning]IPaddress'19
WiFi速度慢什么原因?WiFi速度慢怎么解决?WiFi使用久了,常常出现各种网速慢的问题,下面为大家介绍下解决方法,一起来看看。 WiFi速度慢什么原因
肥佬影音下载速度慢怎么办?小编带来了肥佬影音下载慢解决方法,为什么使用肥佬影音看视频的时候下载那么慢呢?有什么好的解决方法呢?请看下文吧。 首先下载速度慢
迅雷下载速度慢的原因及解决方法如下: 1、可能是网络连接有问题。应检查网络连接,之后重新连接网络即可。 2、可能是网速过差。检测上网速度,结束掉除了迅雷下载