自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

遠(yuǎn)程連接MySQL速度慢的解決

數(shù)據(jù)庫(kù) MySQL
我們今天主要和大家分享的是遠(yuǎn)程連接MySQL速度慢的實(shí)際解決方案,如果你對(duì)這一方案有所了解的話,那么你在實(shí)際操作中就會(huì)如魚得水。

以下的文章主要介紹的是遠(yuǎn)程連接MySQL速度慢的實(shí)際解決方案,即,用skip-name-resolve來(lái)對(duì)DNS的反向進(jìn)行取消的詳細(xì)解析,以下就是文章的具體內(nèi)容的描述,希望在你今后的學(xué)習(xí)中會(huì)有所幫助。
 
PHP遠(yuǎn)程連接MySQL速度慢,有時(shí)遠(yuǎn)程連接到MySQL用時(shí)4-20秒不等,本地連接MySQL正常,出現(xiàn)這種問(wèn)題的主要原因是,默認(rèn)安裝的MySQL開(kāi)啟了DNS的反向解析,在MY.INI(WINDOWS系統(tǒng)下)或MY.CNF(UNIX或LINUX系統(tǒng)下)文件的[MySQLd]下加入skip-name-resolve這一句。

但是,這樣會(huì)引起一個(gè)問(wèn)題:連接MySQL時(shí),不能使用 localhost連接了,而是要使用IP地址的;如果是按localhost對(duì)用戶賦權(quán)限的話,用戶登錄權(quán)限也要修改一下的。

連接MySQL速度慢的解決方法.

2臺(tái)服務(wù)器,一臺(tái)跑iis+php,一臺(tái)跑MySQL,和以往一樣配置好環(huán)境,測(cè)試頁(yè)面一切OK

跑應(yīng)用的時(shí)候發(fā)現(xiàn)php訪問(wèn)MySQL速度很慢,這種情況在以前從未發(fā)現(xiàn)過(guò),雖然2臺(tái)服務(wù)器并非在同一網(wǎng)段中,但是ping數(shù)值基本上都在1,2ms之間,tcp連接應(yīng)該不是問(wèn)題關(guān)健,google以后找到答案,在my.ini文件的[MySQLd]部分加入:skip-name-resolve,保存文件,重啟MySQL,一切OK啦,速度象飛一樣了

新版本的MySQL配置起來(lái)不象以前的那個(gè)傻瓜化了,這個(gè)問(wèn)題折騰了我一上午的時(shí)間,晚上回來(lái)總算是解決了,嘿嘿,又學(xué)到一些東西。

Windows 2003下的MySQL 5服務(wù)器,本機(jī)連接到MySQL服務(wù)非???,局域網(wǎng)內(nèi)有兩臺(tái)Linux機(jī)器,有一臺(tái)連接很快,另外一臺(tái)輸入密碼后要等好幾秒鐘才能連上。

解決辦法:

在MySQL服務(wù)器的配置中增加一個(gè)如下配置后速度飛快。

 

  1. [MySQLd]  
  2. skip-name-resolve 

附錄:( 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.

PHP遠(yuǎn)程連接MySQL速度慢,有時(shí)遠(yuǎn)程連接到MySQL用時(shí)4-20秒不等,本地連接MySQL正常,出現(xiàn)這種問(wèn)題的主要原因是,默認(rèn)安裝的MySQL開(kāi)啟了DNS的反向解析,在MY.INI(WINDOWS系統(tǒng)下)或MY.CNF(UNIX或LINUX系統(tǒng)下)文件的[MySQLd]下加入skip-name-resolve這一句。

MySQL遠(yuǎn)程連接速度慢的解決方法

在局域網(wǎng)內(nèi)連接其他機(jī)器的MySQL,發(fā)現(xiàn)MySQL速度慢的很,不知道什么原因,總有幾秒的延遲.

后來(lái)在網(wǎng)上發(fā)現(xiàn)解決方法,my.ini里面添加

 

  1. [MySQLd]  
  2. skip-name-resolve   
  3. skip-grant-tables 

這樣速度就快了!

 

  1. skip-name-resolve  

選項(xiàng)就能禁用DNS解析,連接速度會(huì)快很多。不過(guò),這樣的話就不能在MySQL的授權(quán)表中使用主機(jī)名了而只能用ip格式。

若使用–skip-grant-tables系統(tǒng)將對(duì)任何用戶的訪問(wèn)不做任何訪問(wèn)控制,但可以用 MySQLadmin flush-privileges或MySQLadmin reload來(lái)開(kāi)啟訪問(wèn)控制;默認(rèn)情況是show databases語(yǔ)句對(duì)所有用戶開(kāi)放,

如果MySQL服務(wù)器沒(méi)有開(kāi)遠(yuǎn)程帳戶,就在my.ini里面加上skip-grant-tables

【編輯推薦】

  1. 讓MySQL支持中文的實(shí)際操作步驟
  2. 配置MySQL與卸載MySQL實(shí)操
  3. MySQL 修改密碼的6個(gè)好用方案
  4. MySQL數(shù)據(jù)庫(kù)訪問(wèn)妙招在Linux之下
  5. 從MySQL數(shù)據(jù)庫(kù)表中來(lái)檢索數(shù)據(jù)并不難

     
責(zé)任編輯:佚名 來(lái)源: 互聯(lián)網(wǎng)
相關(guān)推薦

2010-05-24 08:54:10

2011-09-07 14:55:47

ubuntudns

2019-11-05 10:12:21

MySQL性能查詢

2011-03-08 13:52:25

Proftpd

2019-01-30 08:30:53

MySQL性能數(shù)據(jù)庫(kù)

2011-04-02 16:45:58

SQL Server查詢優(yōu)化

2011-04-02 16:39:53

SQL Server查詢

2010-11-09 11:07:18

2012-05-24 09:53:01

Wi-Fi速度Wi-Fi

2013-01-24 16:42:51

安全寶CDN

2010-06-18 12:37:04

SQL Server查

2011-08-23 08:56:06

Ubuntu11.04Wifi

2010-07-09 09:08:43

2010-07-09 08:46:34

SQL Server查

2018-10-16 14:07:47

SSD固態(tài)硬盤方法

2010-06-29 10:39:48

SQL Server查

2010-06-29 09:56:00

SQL Server查

2014-01-10 14:08:57

WLAN速度優(yōu)化

2021-09-10 22:20:51

WiFi網(wǎng)絡(luò)技術(shù)

2010-11-09 10:54:47

SQL Server查
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)