濮阳杆衣贸易有限公司

主頁(yè) > 知識(shí)庫(kù) > MySQL數(shù)據(jù)庫(kù)遠(yuǎn)程連接很慢的解決方案

MySQL數(shù)據(jù)庫(kù)遠(yuǎn)程連接很慢的解決方案

熱門標(biāo)簽:外呼系統(tǒng)怎樣才能不封號(hào) 如何辦理400客服電話 地圖標(biāo)注百度競(jìng)價(jià) 地圖標(biāo)注什么軟件好用 地圖標(biāo)注專員入駐 外呼系統(tǒng)線路經(jīng)常出問(wèn)題嗎 神行者百貨商場(chǎng)地圖標(biāo)注 安陽(yáng)手機(jī)自動(dòng)外呼系統(tǒng)原理是什么 西藏地圖標(biāo)注改進(jìn)點(diǎn)

有次同事提出開發(fā)使用的MySQL數(shù)據(jù)庫(kù)連接很慢,因?yàn)槲覀兊腗ySQL開發(fā)數(shù)據(jù)庫(kù)是單獨(dú)一臺(tái)機(jī)器部署的,所以認(rèn)為可能是網(wǎng)絡(luò)連接問(wèn)題導(dǎo)致的。

在進(jìn)行 ping和route后發(fā)現(xiàn)網(wǎng)絡(luò)通信都是正常的,而且在MySQL機(jī)器上進(jìn)行本地連接發(fā)現(xiàn)是很快的,所以網(wǎng)絡(luò)問(wèn)題基本上被排除了。以前也遇到過(guò)一次這樣的問(wèn)題,可后來(lái)就不知怎么突然好了,這次又遭遇這樣的問(wèn)題,所以想看看是不是MySQL的配置問(wèn)題。在查詢MySQL相關(guān)文檔和網(wǎng)絡(luò)搜索后,發(fā)現(xiàn)了一個(gè)配置似乎可以解決這樣的問(wèn)題,就是在MySQL的配置文件中增加如下配置參數(shù):

[mysqld]

skip-name-resolve

在Linux下配置文件是/etc/my.cnf,在windows下配置文件是MySQL安裝目錄下的my.ini文件。注意該配置是加在 [mysqld]下面,在更改配置并保存后,然后重啟mysql并遠(yuǎn)程連接測(cè)試,一切恢復(fù)如初。該參數(shù)的官方解釋信息如下:

復(fù)制代碼 代碼如下:
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)致連接很慢,由于我們的開發(fā)機(jī)器是不能夠連接外網(wǎng)的,所以DNS解析是不可能完成的,從而也就明白了為什么連接那么慢了。同時(shí), 請(qǐng)注意在增加該配置參數(shù)后,mysql的授權(quán)表中的host字段就不能夠使用域名而只能夠使用 ip地址了 ,因?yàn)檫@是禁止了域名解析的結(jié)果。

您可能感興趣的文章:
  • MySQL數(shù)據(jù)庫(kù)遠(yuǎn)程連接開啟方法
  • 遠(yuǎn)程連接mysql 授權(quán)方法詳解
  • MySQL遠(yuǎn)程連接丟失問(wèn)題解決方法(Lost connection to MySQL server)
  • mysql 遠(yuǎn)程連接數(shù)據(jù)庫(kù)的方法集合
  • 配置mysql允許遠(yuǎn)程連接的方法
  • 解決遠(yuǎn)程連接mysql很慢的方法(mysql_connect 打開連接慢)
  • navicat無(wú)法遠(yuǎn)程連接mysql的解決方法
  • MYSQL不能從遠(yuǎn)程連接的一個(gè)解決方法(s not allowed to connect to this MySQL server)
  • PHP遠(yuǎn)程連接MYSQL數(shù)據(jù)庫(kù)非常慢的解決方法
  • 詳解遠(yuǎn)程連接Mysql數(shù)據(jù)庫(kù)的問(wèn)題(ERROR 2003 (HY000))
  • 遠(yuǎn)程連接mysql數(shù)據(jù)庫(kù)注意事項(xiàng)記錄(遠(yuǎn)程連接慢skip-name-resolve)

標(biāo)簽:阜陽(yáng) AXB 酒泉 衡水 貴港 萍鄉(xiāng) 張掖 雞西

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《MySQL數(shù)據(jù)庫(kù)遠(yuǎn)程連接很慢的解決方案》,本文關(guān)鍵詞  MySQL,數(shù)據(jù)庫(kù),遠(yuǎn)程,連接,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《MySQL數(shù)據(jù)庫(kù)遠(yuǎn)程連接很慢的解決方案》相關(guān)的同類信息!
  • 本頁(yè)收集關(guān)于MySQL數(shù)據(jù)庫(kù)遠(yuǎn)程連接很慢的解決方案的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    蚌埠市| 宁津县| 古交市| 中卫市| 武隆县| 鄂伦春自治旗| 汪清县| 班玛县| 安阳县| 建阳市| 子长县| 邻水| 邢台市| 长沙市| 桃园市| 海伦市| 开平市| 同江市| 察隅县| 民勤县| 潼南县| 花莲县| 开远市| 黔南| 增城市| 简阳市| 瑞安市| 涿州市| 韩城市| 石城县| 平山县| 比如县| 吉林市| 昭觉县| 平遥县| 阿坝| 东台市| 绵阳市| 彭山县| 开原市| 阳信县|