禁止mysql做域名解析(解決遠(yuǎn)程訪問mysql時(shí)很慢)
更新時(shí)間:2010年04月28日 22:41:10 作者:
當(dāng)遠(yuǎn)程訪問mysql時(shí),mysql會(huì)解析域名,會(huì)導(dǎo)致訪問速度很慢
當(dāng)遠(yuǎn)程訪問mysql時(shí),mysql會(huì)解析域名,會(huì)導(dǎo)致訪問速度很慢,加上下面這個(gè)配置可解決此問題
禁止mysql做域名解析
[mysqld]
skip-name-resolve
PHP遠(yuǎn)程連接MYSQL速度慢,有時(shí)遠(yuǎn)程連接到MYSQL用時(shí)4-20秒不等,本地連接MYSQL正常,出現(xiàn)這種問題的主要原因是,默認(rèn)安裝的MYSQL開啟了DNS的反向解析,在MY.INI(WINDOWS系統(tǒng)下)或MY.CNF(UNIX或LINUX系統(tǒng)下)文件的[mysqld]下加入skip-name-resolve這一句。
但是,這樣會(huì)引起一個(gè)問題:連接mysql時(shí),不能使用 localhost連接了,而是要使用IP地址的;如果是按localhost對用戶賦權(quán)限的話,用戶登錄權(quán)限也要修改一下的。
連接mysql速度慢的解決方法.
2臺(tái)服務(wù)器,一臺(tái)跑iis+php,一臺(tái)跑mysql,和以往一樣配置好環(huán)境,測試頁面一切OK
跑應(yīng)用的時(shí)候發(fā)現(xiàn)php訪問mysql速度很慢,這種情況在以前從未發(fā)現(xiàn)過,雖然2臺(tái)服務(wù)器并非在同一網(wǎng)段中,但是ping數(shù)值基本上都在1,2ms之間,tcp連接應(yīng)該不是問題關(guān)健,google以后找到答案,在my.ini文件的[mysqld]部分加入:skip-name-resolve,保存文件,重啟mysql,一切OK啦,速度象飛一樣了
新版本的mysql配置起來不象以前的那個(gè)傻瓜化了,這個(gè)問題折騰了我一上午的時(shí)間,晚上回來總算是解決了,嘿嘿,又學(xué)到一些東西。
Windows 2003下的MySQL 5服務(wù)器,本機(jī)連接到MySQL服務(wù)非???,局域網(wǎng)內(nèi)有兩臺(tái)Linux機(jī)器,有一臺(tái)連接很快,另外一臺(tái)輸入密碼后要等好幾秒鐘才能連上。
解決辦法:
在MySQL服務(wù)器的配置中增加一個(gè)如下配置后速度飛快。
[mysqld]
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)這種問題的主要原因是,默認(rèn)安裝的MYSQL開啟了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)速度慢的很,不知道什么原因,總有幾秒的延遲.
后來在網(wǎng)上發(fā)現(xiàn)解決方法,my.ini里面添加
[mysqld]
skip-name-resolve
skip-grant-tables
這樣速度就快了!
skip-name-resolve
選項(xiàng)就能禁用DNS解析,連接速度會(huì)快很多。不過,這樣的話就不能在MySQL的授權(quán)表中使用主機(jī)名了而只能用ip格式。
若使用–skip-grant-tables系統(tǒng)將對任何用戶的訪問不做任何訪問控制,但可以用 mysqladmin flush-privileges或mysqladmin reload來開啟訪問控制;默認(rèn)情況是show databases語句對所有用戶開放,
如果mysql服務(wù)器沒有開遠(yuǎn)程帳戶,就在my.ini里面加上skip-grant-tables
禁止mysql做域名解析
[mysqld]
skip-name-resolve
PHP遠(yuǎn)程連接MYSQL速度慢,有時(shí)遠(yuǎn)程連接到MYSQL用時(shí)4-20秒不等,本地連接MYSQL正常,出現(xiàn)這種問題的主要原因是,默認(rèn)安裝的MYSQL開啟了DNS的反向解析,在MY.INI(WINDOWS系統(tǒng)下)或MY.CNF(UNIX或LINUX系統(tǒng)下)文件的[mysqld]下加入skip-name-resolve這一句。
但是,這樣會(huì)引起一個(gè)問題:連接mysql時(shí),不能使用 localhost連接了,而是要使用IP地址的;如果是按localhost對用戶賦權(quán)限的話,用戶登錄權(quán)限也要修改一下的。
連接mysql速度慢的解決方法.
2臺(tái)服務(wù)器,一臺(tái)跑iis+php,一臺(tái)跑mysql,和以往一樣配置好環(huán)境,測試頁面一切OK
跑應(yīng)用的時(shí)候發(fā)現(xiàn)php訪問mysql速度很慢,這種情況在以前從未發(fā)現(xiàn)過,雖然2臺(tái)服務(wù)器并非在同一網(wǎng)段中,但是ping數(shù)值基本上都在1,2ms之間,tcp連接應(yīng)該不是問題關(guān)健,google以后找到答案,在my.ini文件的[mysqld]部分加入:skip-name-resolve,保存文件,重啟mysql,一切OK啦,速度象飛一樣了
新版本的mysql配置起來不象以前的那個(gè)傻瓜化了,這個(gè)問題折騰了我一上午的時(shí)間,晚上回來總算是解決了,嘿嘿,又學(xué)到一些東西。
Windows 2003下的MySQL 5服務(wù)器,本機(jī)連接到MySQL服務(wù)非???,局域網(wǎng)內(nèi)有兩臺(tái)Linux機(jī)器,有一臺(tái)連接很快,另外一臺(tái)輸入密碼后要等好幾秒鐘才能連上。
解決辦法:
在MySQL服務(wù)器的配置中增加一個(gè)如下配置后速度飛快。
[mysqld]
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)這種問題的主要原因是,默認(rèn)安裝的MYSQL開啟了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)速度慢的很,不知道什么原因,總有幾秒的延遲.
后來在網(wǎng)上發(fā)現(xiàn)解決方法,my.ini里面添加
復(fù)制代碼 代碼如下:
[mysqld]
skip-name-resolve
skip-grant-tables
這樣速度就快了!
skip-name-resolve
選項(xiàng)就能禁用DNS解析,連接速度會(huì)快很多。不過,這樣的話就不能在MySQL的授權(quán)表中使用主機(jī)名了而只能用ip格式。
若使用–skip-grant-tables系統(tǒng)將對任何用戶的訪問不做任何訪問控制,但可以用 mysqladmin flush-privileges或mysqladmin reload來開啟訪問控制;默認(rèn)情況是show databases語句對所有用戶開放,
如果mysql服務(wù)器沒有開遠(yuǎn)程帳戶,就在my.ini里面加上skip-grant-tables
您可能感興趣的文章:
- MySQL遠(yuǎn)程訪問設(shè)置終極方法
- MySQL數(shù)據(jù)庫設(shè)置遠(yuǎn)程訪問權(quán)限方法小結(jié)
- mysql數(shù)據(jù)庫遠(yuǎn)程訪問設(shè)置方法
- mysql設(shè)置指定ip遠(yuǎn)程訪問連接實(shí)例
- MySQL數(shù)據(jù)庫遠(yuǎn)程訪問權(quán)限如何打開(兩種方法)
- mysql設(shè)置遠(yuǎn)程訪問數(shù)據(jù)庫的多種方法
- mysql解決遠(yuǎn)程不能訪問的二種方法
- MySQL 不允許從遠(yuǎn)程訪問的解決方法
- 遠(yuǎn)程訪問MySQL數(shù)據(jù)庫的方法小結(jié)
- 一步步教你配置MySQL遠(yuǎn)程訪問
相關(guān)文章
關(guān)于數(shù)據(jù)庫中保留小數(shù)位的問題
本篇文章是對關(guān)于在數(shù)據(jù)庫中保留小數(shù)位的問題進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下2013-07-07
mysql 連接出現(xiàn)Public Key Retrieval is n
在MySQL連接中出現(xiàn)“Public Key Retrieval is not allowed”錯(cuò)誤,通常是因?yàn)樵谑褂冒踩捉幼謱樱⊿SL)連接時(shí)遇到了問題,本文就來介紹一下解決方法,感興趣的可以了解一下2024-03-03
mysql的MVCC多版本并發(fā)控制的實(shí)現(xiàn)
這篇文章主要介紹了mysql的MVCC多版本并發(fā)控制的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2021-04-04
詳解MySQL 5.7 MGR單主確定主節(jié)點(diǎn)方法
這篇文章主要介紹了詳解MySQL 5.7 MGR單主確定主節(jié)點(diǎn)方法,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-09-09

