解决远程连接mysql很慢的问题(mysql_connect 打开连接慢)
[mysqld]
skip-name-resolve
在linux下配置文件是/etc/my.cnf,在windows下配置文件是mysql安装目录下的my.ini文件。注意该配置是加在 [mysqld]下面,在更改配置并保存后,然后重启mysql并远程连接测试,一切恢复如初。该参数的官方解释信息如下:(http://www.my400800.cn)
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地址了,因为这是禁止了域名解析的结果。
转载于:https://www.cnblogs.com/jishu/archive/2011/06/29/2093043.html
解决远程连接mysql很慢的问题(mysql_connect 打开连接慢)相关推荐
- 解决远程连接mysql很慢的方法(mysql_connect 打开连接慢)
解决远程连接mysql很慢的方法(mysql_connect 打开连接慢) 参考文章: (1)解决远程连接mysql很慢的方法(mysql_connect 打开连接慢) (2)https://www. ...
- 解决远程连接mysql很慢的方法
解决远程连接mysql很慢的方法 参考文章: (1)解决远程连接mysql很慢的方法 (2)https://www.cnblogs.com/xiaoxihebei/p/5893887.html 备忘一 ...
- navicat远程连接mysql很慢_解决Navicat远程连接mysql很慢的方法
ubuntu 下 /etc/mysql/mysql.conf.d [mysqld] skip-name-resolve 增加该字段即可 如果增加该字段,这无法使用本地ip进行登入, 登陆到MySql ...
- php没有mysql_connect()_【在线等】php不能连接mysql?提示:Warning: mysql_connect() 。。。...
你的位置: 问答吧 -> PHP基础 -> 问题详情 [在线等]php不能连接mysql?提示:Warning: mysql_connect() ... 连接时提示: Warning: m ...
- navicat连接mysql mac_Mac OS下,使用Navicat连接MySQL出现的问题
问题1:安装了最新版本的MySQL(mysql-8.0.12-macos10.13-x86_64),但是Navicat版本过低,导致连接MySQL一直报"Can't connect to M ...
- 解决Windows环境下PHP连接MySQL很慢的问题
接触到一个网站,静态资源和接口都在同一台服务器,静态资源加载很快,都是几十上百毫秒就可以加载,但是接口请求都很慢,平均有6-7秒. 先查看了接口请求日志,发现每个接口的执行时间确实都很长,查看接口代码 ...
- 登录mysql 1130_解决远程登录mysql数据库报1130错误-阿里云开发者社区
现象:安装好mysql后,发现phpmyadmin不能登录mysql,返回1130错误,如下图: 但是在mysql命令行登录mysql -u root -p可以.分析过程及解决方案: 百度查询mysq ...
- dbcp连接mysql,8小时会自动断开连接
为什么80%的码农都做不了架构师?>>> 最近自己做一个项目用到dbcp连接mysql,开始时很正常,可是第二天再访问服务时就出问题了,mysql连接关闭了. mysql在空闲 ...
- matlab 连接mysql数据库_【转】matlab 连接 mysql 数据库
首先要安装mysql驱动程序包,详细步骤如下: Step 1: 将mysql-connector-java-5.1.7-bin.jar文件拷贝到......\MATLAB\R2009a\java\ja ...
最新文章
- Promise深度学习---我のPromise/A+实现
- Mybatis报错 元素内容必须由格式正确的字符数据或标记组成
- 读书笔记_java设计模式深入研究 第八章 状态模式 State
- Spring MVC 学习笔记 json格式的输入和输出
- 博科查看光功率_法拉第旋光器:非互易性旋转光的偏振
- python中dtype什么意思_浅谈python 中的 type(), dtype(), astype()的区别
- 自己封装了的AlertController
- 常用的数据库操作语句(3)
- iOS code collection
- 小米 samba linux,解决小米路由器升级固件后samba无法访问一例
- 基于python的图像处理的毕业论文_图像处理毕业论文 精品
- django微信公众号开发入门详细指南
- 简历里计算机能力,简历上计算机能力怎么写
- 西门子em235模块的功能_多图细讲,模拟量模块与变送器的接线
- 跑道标识和那些复杂的灯光系统 and 简介、编号、参数、标志及数量 and 飞机跑道标准与参数...
- CE1到9关详细教程
- 互联网日报 | 5月31日 星期一 | 天猫618取消PK玩法;有赞独立新零售业务品牌;钉钉发布国内首个低代码应用广场“钉钉搭”...
- 手机浏览器点击input放大问题
- 操作系统中四步法实现PV操作
- 迁移到行业标准格式PKCS12