MySql使用skip-name-resolve解決外網連線客戶端過慢如何解決

小云云
發布: 2017-12-25 14:24:50
原創
2261 人瀏覽過

本文主要和大家分享MySql使用skip-name-resolve解決外網連結客戶端過慢問題該如何解決。在騰訊雲上面搭建的mysql使用開發的電腦上navicat進行訪問時總是特別的慢,原來是Mysql會對請求的地址進行域名解析,開發的電腦並沒有域名,所以會導致特別的慢。

在騰訊雲上面搭建的mysql使用開發的電腦上navicat進行訪問時總是特別的慢,原來是Mysql會對請求的地址進行域名解析,開發的電腦並沒有域名,所以會導致特別的慢,使用以下進行解決


[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 hosthostbyaddr_r() and gethostbyname_r() to resolve the hostAname. 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 no other 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 thisase youon however on youonly 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 incve sing 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## you don't want to allow
connections over TCP/IP, you can do this by starting mysqld with
–skip-networking.

#根據文件說明,如果你的mysql主機查詢DNS很慢或是有很多客戶端主機時會導致連接很慢,由於我們的開發機器是不能夠連接外網的,所以DNS解析是不可能完成的,從而也就明白了為什麼連接那麼慢了。同時,請注意在增加該設定參數後,mysql的授權表中的host欄位就不能夠使用網域而只能夠使用 ip位址了,因為這是禁止了網域解析的結果。

相關推薦:


python http長連線客戶端實例教學

MySQL DNS反解析過慢問題的解決方法

解決mysql連接過慢的方法_MySQL#

以上是MySql使用skip-name-resolve解決外網連線客戶端過慢如何解決的詳細內容。更多資訊請關注PHP中文網其他相關文章!

相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!