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

[mysqld]skip-name-resolveskip-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地址了,因为这是禁止了域名解析的结果。

总结

更多相关文章

  1. Linux下MYSQL 5.7 找回root密码的问题(亲测可用)
  2. Android(安卓)10 定位问题,获取NMEA(支持5.0~10.0)
  3. mybatisplus的坑 insert标签insert into select无参数问题的解决
  4. 关于Android(安卓)Studio3.2新建项目Android(安卓)resource link
  5. Android软键盘适配问题
  6. SlidingMenu和ActionBarSherlock结合做出出色的App布局,Facebook
  7. android解决坚屏拍照和保存图片旋转90度的问题,并兼容4.0
  8. Android(安卓)Calendar使用过程中遇到的问题
  9. flutter-使用第三方库,编译和运行版本不一致问题 2

随机推荐

  1. Android核心分析(20)----Android应用程序
  2. PermissionX现在支持Java了!还有Android(
  3. Android 开发艺术探索笔记 前四章
  4. Android Studio主题设置
  5. 我的Android 4 学习系列之开始入手:配置开
  6. 初学Android快速上手经验(自我小结)
  7. 像SpringMVC一样在Android上做Web开发
  8. 如何从云端推送消息到手机 (Android(安卓
  9. Android(安卓)悬浮窗权限各机型各系统适
  10. Android系列之Android系列之如何成为Andr