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

标签:mysql,skip,name,resolve
0
投稿

猜你喜欢

  • Python如何实现定时器功能

    2023-04-13 23:19:28
  • python logging 重复写日志问题解决办法详解

    2021-04-29 13:19:30
  • python3.6环境安装+pip环境配置教程图文详解

    2022-02-07 11:28:36
  • python中datetime模块中strftime/strptime函数的使用

    2023-11-15 15:02:46
  • golang常用库之pkg/errors包第三方错误处理包案例详解

    2024-02-14 09:20:38
  • Python计算标准差之numpy.std和torch.std的区别

    2022-08-17 11:38:14
  • Python调用工具包实现发送邮件服务

    2023-08-30 02:25:16
  • 简单触发器的使用 献给SQL初学者

    2024-01-17 18:27:18
  • python如何将mat文件转为png

    2023-04-14 07:37:21
  • asp下实现代码的“运行代码”“复制代码”“保存代码”功能源码

    2011-04-14 10:39:00
  • MYSQL SERVER收缩日志文件实现方法

    2024-01-26 15:14:29
  • PHP registerXPathNamespace()函数讲解

    2023-06-05 01:58:00
  • python单线程实现多个定时器示例

    2023-05-11 08:59:18
  • js自定义鼠标右键的实现原理及源码

    2024-04-28 09:51:39
  • tensorflow多维张量计算实例

    2022-02-05 00:43:48
  • python列表[list]和元组(tuple)详情

    2022-05-23 01:14:31
  • php+正则将字符串中的字母数字和中文分割

    2024-04-10 10:56:42
  • 关于Python自动化操作Excel

    2022-07-19 23:25:48
  • 图片自适应宽度新解决方法

    2009-09-22 14:55:00
  • vue2.0开发实践总结之疑难篇

    2024-05-02 16:33:28
  • asp之家 网络编程 m.aspxhome.com