MySql使用skip-name-resolve解決外網(wǎng)鏈接客戶端過(guò)慢問(wèn)題
在騰訊云上面搭建的mysql使用開(kāi)發(fā)的電腦上navicat進(jìn)行訪問(wèn)時(shí)總是特別的慢,原來(lái)是Mysql會(huì)對(duì)請(qǐng)求的地址進(jìn)行域名解析,開(kāi)發(fā)的電腦并沒(méi)有域名,所以會(huì)導(dǎo)致特別的慢,使用以下進(jìn)行解決
[mysqld] skip-name-resolve skip-grant-tables
官方的解釋
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.
根據(jù)文檔說(shuō)明,如果你的mysql主機(jī)查詢DNS很慢或是有很多客戶端主機(jī)時(shí)會(huì)導(dǎo)致連接很慢,由于我們的開(kāi)發(fā)機(jī)器是不能夠連接外網(wǎng)的,所以DNS解析是不可能完成的,從而也就明白了為什么連接那么慢了。同時(shí),請(qǐng)注意在增加該配置參數(shù)后,mysql的授權(quán)表中的host字段就不能夠使用域名而只能夠使用 ip地址了,因?yàn)檫@是禁止了域名解析的結(jié)果。
總結(jié)
以上所述是小編給大家介紹的MySql使用skip-name-resolve解決外網(wǎng)鏈接客戶端過(guò)慢問(wèn)題,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
相關(guān)文章
Ubuntu安裝Mysql+啟用遠(yuǎn)程連接的完整過(guò)程
這篇文章主要介紹了Ubuntu如何安裝Mysql+啟用遠(yuǎn)程連接,用ssh客戶端或者云服務(wù)器廠家提供的網(wǎng)頁(yè)版控制臺(tái)都行,只要你能連上服務(wù)器就行,需要的朋友可以參考下2022-06-06
如何解決Mysql報(bào)錯(cuò)Deadlock found when trying to
這篇文章主要介紹了如何解決Mysql報(bào)錯(cuò)Deadlock found when trying to get lock;try restarting transaction問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2024-05-05
MySQL使用distinct去掉查詢結(jié)果重復(fù)的問(wèn)題
這篇文章主要介紹了MySQL使用distinct去掉查詢結(jié)果重復(fù)的問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2024-01-01
實(shí)現(xiàn)MySQL回滾的Python腳本的編寫(xiě)教程
這篇文章主要介紹了實(shí)現(xiàn)MySQL回滾的Python腳本的編寫(xiě)教程,文中的回滾針對(duì)的是DELETE語(yǔ)句的數(shù)據(jù)庫(kù)誤操作,需要的朋友可以參考下2015-11-11
mysql中sum float類型使用小數(shù)點(diǎn)的方法
使用sum示和時(shí)如果是float類型的數(shù)據(jù)就會(huì)出現(xiàn)小數(shù)點(diǎn)了,那么要如何解決這個(gè)問(wèn)題,下面介紹二種方法2013-11-11
mysql的sql語(yǔ)句特殊處理語(yǔ)句總結(jié)(必看)
下面小編就為大家?guī)?lái)一篇mysql的sql語(yǔ)句特殊處理語(yǔ)句總結(jié)(必看)。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2017-03-03
Mysql使用insert插入多條記錄 批量新增數(shù)據(jù)
這篇文章主要介紹了Mysql使用insert插入多條記錄批量新增數(shù)據(jù),需要的朋友可以參考下2017-08-08
MySQL中crash safe數(shù)據(jù)完整性機(jī)制面試精講
這篇文章主要為大家介紹了MySQL數(shù)據(jù)完整性crash safe特性面試精講,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-10-10

