菜单 学习猿地 - LMONKEY

VIP

开通学习猿地VIP

尊享10项VIP特权 持续新增

知识通关挑战

打卡带练!告别无效练习

接私单赚外块

VIP优先接,累计金额超百万

学习猿地私房课免费学

大厂实战课仅对VIP开放

你的一对一导师

每月可免费咨询大牛30次

领取更多软件工程师实用特权

入驻
149
0

连接MySql速度慢的解决方法(skip-name-resolve)

原创
05/13 14:22
阅读数 771752

原因是默认安装的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 gethostbyahttp://www.cppcns.comddr_r() and gethostbyname_r() to resolve the hostname.

If the operating system doesn't support the above BhxdXZJGithrBhxdXZJGiead-safe calls, the thread will lock a mutex and call gethostbyaddr() and gethostbyn编程客栈ame() 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.http://www.cppcns.com 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

本文标题: 连接MySql速度慢的解决方法(skip-name-resolve)
本文地址: http://www.cppcns.com/shujuku/mysql/131623.html

发表评论

0/200
149 点赞
0 评论
收藏
为你推荐 换一批