欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

連接MySql速度慢的解決方法(skip-name-resolve)

 更新時(shí)間:2015年09月23日 17:56:19   投稿:mdxy-dxy  
這篇文章主要介紹了連接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

相關(guān)文章

  • MySQL mysqladmin客戶端的使用簡介

    MySQL mysqladmin客戶端的使用簡介

    這篇文章主要介紹了MySQL mysqladmin客戶端的使用簡介,幫助大家更好的理解和學(xué)習(xí)使用MySQL,感興趣的朋友可以了解下
    2021-03-03
  • Mysql auto_increment 重新計(jì)數(shù)(讓id從1開始)

    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占用高的問題

    使用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-03
  • php連接不上mysql但mysql命令行操作正常的解決方法

    php連接不上mysql但mysql命令行操作正常的解決方法

    這篇文章主要介紹了php連接不上mysql但mysql命令行操作正常的解決方法,需要的朋友可以參考下
    2014-04-04
  • MySQL中(JOIN/ORDER BY)語句的查詢過程及優(yōu)化方法

    MySQL中(JOIN/ORDER BY)語句的查詢過程及優(yōu)化方法

    sql語句性能達(dá)不到你的要求,執(zhí)行效率讓你忍無可忍,一般會(huì)造成很多影響。那么我們?nèi)绾谓鉀Q這些問題呢,下面由小編來和大家簡單講下
    2019-05-05
  • 深入理解Mysql中的MVCC

    深入理解Mysql中的MVCC

    這篇文章主要介紹了深入理解Mysql中的MVCC,同樣的sql查詢語句在一個(gè)事務(wù)?里多次執(zhí)行查詢結(jié)果相同,就算其它事務(wù)對(duì)數(shù)據(jù)有修改也不會(huì)影響當(dāng)前事務(wù)sql語句的查詢結(jié)果,?這個(gè)隔離性就是靠MVCC機(jī)制來保證的,需要的朋友可以參考下
    2023-09-09
  • 解決mysql 1040錯(cuò)誤Too many connections的方法

    解決mysql 1040錯(cuò)誤Too many connections的方法

    因?yàn)槟愕膍ysql安裝目錄下的my.ini中設(shè)定的并發(fā)連接數(shù)太少或者系統(tǒng)繁忙導(dǎo)致連接數(shù)被占滿
    2012-09-09
  • Mysql表創(chuàng)建外鍵報(bào)錯(cuò)解決方案

    Mysql表創(chuàng)建外鍵報(bào)錯(cuò)解決方案

    這篇文章主要介紹了Mysql表創(chuàng)建外鍵報(bào)錯(cuò)解決方案,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2020-09-09
  • mysql仿asp的數(shù)據(jù)庫操作類

    mysql仿asp的數(shù)據(jù)庫操作類

    使用說明: 該類完全按照ADO的習(xí)慣書寫的,用過ASP的人都覺得ASP連接數(shù)據(jù)庫比PHP好用(這是我的感覺), 但PHP得一個(gè)一個(gè)API地寫,挺累,該類做了完全的封裝 創(chuàng)建類的實(shí)例時(shí)可以指定一個(gè)數(shù)據(jù)庫表和選擇的數(shù)據(jù)庫,如:new MySQLDB("table","database");
    2008-04-04
  • Mysql中STR_TO_DATE函數(shù)使用(字符串轉(zhuǎn)為日期/時(shí)間值)

    Mysql中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

最新評(píng)論