連接MySql速度慢的解決方法(skip-name-resolve)
最近在Linux服務(wù)器上安裝MySql5后,本地使用客戶端連MySql速度超慢,本地程序連接也超慢。
解決方法:在配置文件my.cnf的[mysqld]下加入skip-name-resolve。
原因是默認(rèn)安裝的MySql開啟了DNS的反向解析。如果禁用的話就不能在MySQL的授權(quán)表中使用主機(jī)名了而只能用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: 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.
或者h(yuǎn)ost中添加
192.168.1.21 N-21
- mysql 加了 skip-name-resolve不能鏈接數(shù)據(jù)庫問題的解決方法
- Mysql DNS反向解析導(dǎo)致連接超時(shí)過程分析(skip-name-resolve)
- mysql啟用skip-name-resolve模式時(shí)出現(xiàn)Warning的處理辦法
- 遠(yuǎn)程連接mysql數(shù)據(jù)庫注意事項(xiàng)記錄(遠(yuǎn)程連接慢skip-name-resolve)
- mysql SKIP-NAME-RESOLVE 錯(cuò)誤的使用時(shí)機(jī)造成用戶權(quán)限
- MySql使用skip-name-resolve解決外網(wǎng)鏈接客戶端過慢問題
相關(guān)文章
Mysql auto_increment 重新計(jì)數(shù)(讓id從1開始)
當(dāng)清空一個(gè)表的時(shí)候,重新插入數(shù)據(jù),發(fā)現(xiàn)auto_increment屬性的字段計(jì)數(shù)不是從1開始的時(shí)候,可以使用以下命令2012-12-12使用MySQL Slow Log來解決MySQL CPU占用高的問題
在Linux VPS系統(tǒng)上有時(shí)候會(huì)發(fā)現(xiàn)MySQL占用CPU高,導(dǎo)致系統(tǒng)的負(fù)載比較高。這種情況很可能是某個(gè)SQL語句執(zhí)行的時(shí)間太長導(dǎo)致的。優(yōu)化一下這個(gè)SQL語句或者優(yōu)化一下這個(gè)SQL引用的某個(gè)表的索引一般能解決問題2013-03-03php連接不上mysql但mysql命令行操作正常的解決方法
這篇文章主要介紹了php連接不上mysql但mysql命令行操作正常的解決方法,需要的朋友可以參考下2014-04-04MySQL中(JOIN/ORDER BY)語句的查詢過程及優(yōu)化方法
sql語句性能達(dá)不到你的要求,執(zhí)行效率讓你忍無可忍,一般會(huì)造成很多影響。那么我們?nèi)绾谓鉀Q這些問題呢,下面由小編來和大家簡單講下2019-05-05解決mysql 1040錯(cuò)誤Too many connections的方法
因?yàn)槟愕膍ysql安裝目錄下的my.ini中設(shè)定的并發(fā)連接數(shù)太少或者系統(tǒng)繁忙導(dǎo)致連接數(shù)被占滿2012-09-09Mysql表創(chuàng)建外鍵報(bào)錯(cuò)解決方案
這篇文章主要介紹了Mysql表創(chuàng)建外鍵報(bào)錯(cuò)解決方案,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2020-09-09Mysql中STR_TO_DATE函數(shù)使用(字符串轉(zhuǎn)為日期/時(shí)間值)
這篇文章主要給大家介紹了關(guān)于Mysql中STR_TO_DATE函數(shù)使用的相關(guān)資料,STR_TO_DATE函數(shù)的主要功能是字符串轉(zhuǎn)為日期/時(shí)間值,文中通過示例代碼介紹的非常詳細(xì),需要的朋友可以參考下2022-09-09