MySql使用skip-name-resolve解决外网连接客户端过慢如何解决


本文摘自PHP中文网,作者小云云,侵删。

本文主要和大家分享MySql使用skip-name-resolve解决外网链接客户端过慢问题该如何解决。在腾讯云上面搭建的mysql使用开发的电脑上navicat进行访问时总是特别的慢,原来是Mysql会对请求的地址进行域名解析,开发的电脑并没有域名,所以会导致特别的慢。

在腾讯云上面搭建的mysql使用开发的电脑上navicat进行访问时总是特别的慢,原来是Mysql会对请求的地址进行域名解析,开发的电脑并没有域名,所以会导致特别的慢,使用以下进行解决


1

2

3

[mysqld]

skip-name-resolve

skip-grant-tables

官方的解释

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
?Cskip-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 lookop
with ?Cskip-name-resolve or by increasing the HOST_CACHE_SIZE define
(default: 128) and recompile mysqld. You can disable the hostname
cache with ?Cskip-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
?Cskip-networking.

根据文档说明,如果你的mysql主机查询DNS很慢或是有很多客户端主机时会导致连接很慢,由于我们的开发机器是不能够连接外网的,所以DNS解析是不可能完成的,从而也就明白了为什么连接那么慢了。同时,请注意在增加该配置参数后,mysql的授权表中的host字段就不能够使用域名而只能够使用 ip地址了,因为这是禁止了域名解析的结果。

相关推荐:

python http长连接客户端实例教程

MySQL DNS反解析过慢问题的解决办法

解决mysql连接过慢的方法_MySQL

以上就是MySql使用skip-name-resolve解决外网连接客户端过慢如何解决的详细内容,更多文章请关注木庄网络博客

相关阅读 >>

mysql全文索引实现简单版搜索引擎实例代码

mysql如何导出表的字段和相关属性(附示例)

mysql 无法成功启动服务怎么办

mysql转储/恢复存储过程和触发器

mysql中索引与from_unixtime的问题详解

mysql中的数据类型和schema优化

mysql 8.0.2复制新特性的详细介绍

mysql如何增加字段

mysql如何实现数据切分

mysql中的router是什么

更多相关阅读请进入《skip-name-resolve》频道 >>


数据库系统概念 第6版
书籍

数据库系统概念 第6版

机械工业出版社

本书主要讲述了数据模型、基于对象的数据库和XML、数据存储和查询、事务管理、体系结构等方面的内容。



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...