mysql跨库操作速度慢的解决方案
来源:互联网 发布:js作用域和this关键字 编辑:程序博客网 时间:2024/05/21 22:40
远程连接mysql速度慢的解决方法:skip-name-resolve取消DNS的反向解析
PHP远程连接MYSQL速度慢,有时远程连接到MYSQL用时4-20秒不等,本地连接MYSQL正常,出现这种问题的主要原因是,默认安装的MYSQL开启了DNS的反向解析,在MY.INI(WINDOWS系统下)或MY.CNF(UNIX或LINUX系统下)文件的[mysqld]下加入skip-name-resolve这一句。
但是,这样会引起一个问题:连接mysql时,不能使用 localhost连接了,而是要使用IP地址的;如果是按localhost对用户赋权限的话,用户登录权限也要修改一下的。
连接mysql速度慢的解决方法.
2台服务器,一台跑iis+php,一台跑mysql,和以往一样配置好环境,测试页面一切OK
跑应用的时候发现php访问mysql速度很慢,这种情况在以前从未发现过,虽然2台服务器并非在同一网段中,但是ping数值基本上都在1,2ms之间,tcp连接应该不是问题关健,google以后找到答案,在my.ini文件的[mysqld]部分加入:skip-name-resolve,保存文件,重启mysql,一切OK啦,速度象飞一样了
新版本的mysql配置起来不象以前的那个傻瓜化了,这个问题折腾了我一上午的时间,晚上回来总算是解决了,嘿嘿,又学到一些东西。
Windows 2003下的MySQL 5服务器,本机连接到MySQL服务非常快,局域网内有两台Linux机器,有一台连接很快,另外一台输入密码后要等好几秒钟才能连上。
解决办法:
在MySQL服务器的配置my.ini中增加一个如下配置后速度飞快。
[mysqld]
skip-name-resolve
这样速度就快了!
[mysqld]
skip-grant-tables
选项就能禁用DNS解析,连接速度会快很多。不过,这样的话就不能在MySQL的授权表中使用主机名了而只能用ip格式。
若使用skip-grant-tables系统将对任何用户的访问不做任何访问控制,但可以用 mysqladmin flush-privileges或mysqladmin reload来开启访问控制;默认情况是show databases语句对所有用户开放,
如果mysql服务器没有开远程帐户,就在my.ini里面加上skip-grant-tables
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跨库操作速度慢的解决方案
- 数据库操作时,速度慢的解决方案
- mysql远程连接速度慢的解决方案
- mysql 远程连接速度慢的解决方案
- mysql 远程连接速度慢的解决方案
- mysql 远程连接速度慢的解决方案
- PHP远程连接MYSQL速度慢的解决方案
- myeclipse 运行速度慢的解决方案
- adsl 上传速度慢 的解决方案
- 使用npm 安装速度慢的解决方案
- pod install速度慢的终极解决方案
- Dedecms生成速度慢的解决方案
- github clone速度慢的解决方案
- pod install速度慢的终极解决方案
- 存储过程中存在跨库操作,速度慢
- 连接mysql速度慢的解决方法
- MYSQL远程连接速度慢的解决方法
- 远程连接mysql速度慢的解决方法
- 一个关于sql语句的问题解决,包括:字符串拆分,游标
- cookie模板
- 一篇很全面的freemarker教程
- Java如何每5秒生成一个随机数
- C++学习笔记20140314
- mysql跨库操作速度慢的解决方案
- Ubuntu jsp平台使用JDBC来连接MySQL数据库
- cocos2d-x游戏开发 跑酷(三) 人物跑动
- 链表
- Ubuntu-13.04-X86_64安装GT630驱动
- MySQL: ubuntu10.10 下与 JDBC 操作
- HDU 1327 map
- 黑马程序员---银行业务调度系统
- C++编程 - 真的不要重复造轮子吗