位置: 编程技术 - 正文
推荐整理分享MySql使用skip-name-resolve解决外网链接客户端过慢问题(Mysql使用or如何优化),希望有所帮助,仅作参考,欢迎阅读内容。
文章相关热门搜索词:Mysql使用过程,mysql使用表命令,Mysql使用or如何优化,Mysql使用中的句柄,Mysql使用循环语录求1-100的和,Mysql使用教程,mysql使用表命令,mysql使用binlog恢复数据,内容如对您有帮助,希望把文章链接给更多的朋友!
在腾讯云上面搭建的mysql使用开发的电脑上navicat进行访问时总是特别的慢,原来是Mysql会对请求的地址进行域名解析,开发的电脑并没有域名,所以会导致特别的慢,使用以下进行解决
官方的解释
How MySQLuses DNS When a new thread connects to mysqld, mysqld willspawn a new thread to handle the request. This thread will first checkif the hostname is in the hostname cache. If not the thread will callgethostbyaddr_r() and gethostbyname_r() to resolve the hostname. Ifthe operating system doesn't support the above thread-safe calls, thethread will lock a mutex and call gethostbyaddr() and gethostbyname()instead. Note that in this case no other thread can resolve otherhostnames that is not in the hostname cache until the first thread isready. You can disable DNS host lookup by starting mysqld with?skip-name-resolve. In this case you can however only use IP names inthe MySQL privilege tables. If you have a very slow DNS and manyhosts, you can get more performance by either disabling DNS lookopwith ?skip-name-resolve or by increasing the HOST_CACHE_SIZE define(default: ) and recompile mysqld. You can disable the hostnamecache with ?skip-host-cache. You can clear the hostname cache withFLUSH HOSTS or mysqladmin flush-hosts. If you don't want to allowconnections over TCP/IP, you can do this by starting mysqld with?skip-networking.
根据文档说明,如果你的mysql主机查询DNS很慢或是有很多客户端主机时会导致连接很慢,由于我们的开发机器是不能够连接外网的,所以DNS解析是不可能完成的,从而也就明白了为什么连接那么慢了。同时,请注意在增加该配置参数后,mysql的授权表中的host字段就不能够使用域名而只能够使用 ip地址了,因为这是禁止了域名解析的结果。
总结
以上所述是小编给大家介绍的MySql使用skip-name-resolve解决外网链接客户端过慢问题,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对积木网网站的支持!
修改mysql允许主机访问的权限方法 开启mysql的远程访问权限默认mysql的用户是没有远程访问的权限的,因此当程序跟数据库不在同一台服务器上时,我们需要开启mysql的远程访问权限。主
mysql执行sql文件报错Error: Unknown storage engine‘InnoDB’的解决方法 发现问题最近在工作中遇到一个问题,在运行了一个innoDB类型的sql文件,报了Error:Unknownstorageengine'InnoDB'错误,网上查了很多方法,但是都没办法真正解
IOS 数据库升级数据迁移的实例详解 IOS数据库升级数据迁移的实例详解概要:很久以前就遇到过数据库版本升级的引用场景,当时的做法是简单的删除旧的数据库文件,重建数据库和表结
标签: Mysql使用or如何优化
本文链接地址:https://www.jiuchutong.com/biancheng/348665.html 转载请保留说明!友情链接: 武汉网站建设