MySql使用skip-name-resolve解决外网链接客户端过慢问题
作者:mrr 发布时间:2024-01-26 16:07:35
在腾讯云上面搭建的mysql使用开发的电脑上navicat进行访问时总是特别的慢,原来是Mysql会对请求的地址进行域名解析,开发的电脑并没有域名,所以会导致特别的慢,使用以下进行解决
[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
–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 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.
根据文档说明,如果你的mysql主机查询DNS很慢或是有很多客户端主机时会导致连接很慢,由于我们的开发机器是不能够连接外网的,所以DNS解析是不可能完成的,从而也就明白了为什么连接那么慢了。同时,请注意在增加该配置参数后,mysql的授权表中的host字段就不能够使用域名而只能够使用 ip地址了,因为这是禁止了域名解析的结果。
总结
以上所述是小编给大家介绍的MySql使用skip-name-resolve解决外网链接客户端过慢问题网站的支持!
来源:http://www.2cto.com/database/201707/661925.html


猜你喜欢
- 找到nginx多网站配置文件:类似 nginx/sites-available/www.baidu.comserver { li
- 解析接口返回数据1、把json格式的数据转换成单个{key,value}的形式,并把每个dict存入listdef parse(self,d
- scrapy是目前python使用的最广泛的爬虫框架架构图如下解释:Scrapy Engine(引擎): 负责Spider、ItemPipe
- 我就废话不多说了,大家还是直接看代码吧~import kerasfrom sklearn.model_selection import tr
- 个人觉得还是不要使用中文作为文件名的好,虽然我们用的语言是中文,毕竟中文容易出现问题,兼容性不好。用Dreamweaver制作网页时,如果插
- Background之前数据库只区分了Android,IOS两个平台,游戏上线后现在PM想要区分国服,海外服,港台服。这几个字段从前端那里的
- 如何修改NT的登录密码? 代码见下:<%Sub ChangeUserPassword(C
- --用SQL多条可以将多条数据组成一棵XML树L一次插入 --将XML树作为varchar参数传入用 --insert xx select
- 引入先安装三个模块pip install channelspip install channels_redispip install pyw
- 1.解读tensorflow权重文件,透过 tf.train.NewCheckpointReader函数。2.reader.get_vari
- 柱形图bar()函数绘制柱形图import matplotlib.pyplot as plx = [1,2,3,4,5,6,7]y = [1
- 下面就是JavaScript实现大文件上传功能的代码bigFileUpload.jsconst path = require('pa
- 我们将学习如何通过一种称为修复的方法去除旧照片中的小噪音,笔画等。基本思路很简单:用相邻像素替换那些坏标记,使其看起来像邻域。cv2.inp
- Scrapy框架简单介绍Scrapy框架是一个基于Twisted的异步处理框架,是纯Python实现的爬虫框架,是提取结构性数据而编写的应用
- 我之前想写路由器的密码暴力破解器,我手上只有极路由,发现极路由有安全限制,只能允许连续10密码错误,所以我改拿博客园练手。博客园的博客有个功
- 在《多进程并发与同步》中介绍了进程创建与信息共享,除此之外python还提供了更方便的进程间通讯方式。进程间通讯multiprocessin
- 本文实例讲述了Python pandas自定义函数的使用方法。分享给大家供大家参考,具体如下:自定义函数的使用import numpy as
- 本文实例讲述了flask框架路由常用定义方式。分享给大家供大家参考,具体如下:路由的各种定义方式请求方式限定使用 methods 参数指定可
- 如何在 git 中取消 pycache 文件如果使用 PyCharm 运行代码,会在 Python 脚本所在目录生成 __pycache__
- Swin TransformerSwin Transformer是一种用于图像处理的深度学习模型,它可以用于各种计算机视觉任务,如图像分类、