位置: 编程技术 - 正文
推荐整理分享连接MySql速度慢的解决方法(skip-name-resolve)(mysql太慢),希望有所帮助,仅作参考,欢迎阅读内容。
文章相关热门搜索词:mysql连接很慢,mysql数据库连接慢,mysql连接很慢,mysql太慢,mysql连接很慢,mysql连接很慢,mysql 速度慢,mysql连接很慢,内容如对您有帮助,希望把文章链接给更多的朋友!
最近在Linux服务器上安装MySql5后,本地使用客户端连MySql速度超慢,本地程序连接也超慢。解决方法:在配置文件my.cnf的[mysqld]下加入skip-name-resolve。
原因是默认安装的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 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 lookup with --skip-name-resolve or by increasing the HOST_CACHE_SIZE define (default: ) 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中添加
..1. N-
lnmp下如何关闭Mysql日志保护磁盘空间 LNMP一键包安装的Mysql默认开启Mysql日志,如果网站对数据库读写较为频繁的话可能会产生大量日志,并占用磁盘空间,还有可能导致VPS的硬盘闲置空间消
Navicat for MySQL(mysql图形化管理工具)是什么? MySQL现已经成为大多数中小企业及个人站长建站的首选数据库,其自带了简单web图形管理phpmyadmin工具,但是管理、操作能力有限,这就使得人们常需要
使用phpMyAdmin批量修改Mysql数据表前缀的方法 多个网站共用一个Mysql数据库时,为使数据库管理不混乱,一般采用不同的网站使用不同前缀名的方式进行区分。而如何批量修改已有数据库的前缀名呢
标签: mysql太慢
本文链接地址:https://www.jiuchutong.com/biancheng/348005.html 转载请保留说明!友情链接: 武汉网站建设