国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數據庫 > MySQL > 正文

禁止mysql做域名解析(解決遠程訪問mysql時很慢)

2024-07-24 12:43:49
字體:
來源:轉載
供稿:網友
當遠程訪問mysql時,mysql會解析域名,會導致訪問速度很慢,加上下面這個配置可解決此問題

禁止mysql做域名解析
[mysqld]

skip-name-resolve


PHP遠程連接MYSQL速度慢,有時遠程連接到MYSQL用時4-20秒不等,本地連接MYSQL正常,出現這種問題的主要原因是,默認安裝的MYSQL開啟了DNS的反向解析,在MY.INI(WINDOWS系統下)或MY.CNF(UNIX或LINUX系統下)文件的[mysqld]下加入skip-name-resolve這一句。

但是,這樣會引起一個問題:連接mysql時,不能使用 localhost連接了,而是要使用IP地址的;如果是按localhost對用戶賦權限的話,用戶登錄權限也要修改一下的。

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

2臺服務器,一臺跑iis+php,一臺跑mysql,和以往一樣配置好環境,測試頁面一切OK

跑應用的時候發現php訪問mysql速度很慢,這種情況在以前從未發現過,雖然2臺服務器并非在同一網段中,但是ping數值基本上都在1,2ms之間,tcp連接應該不是問題關健,google以后找到答案,在my.ini文件的[mysqld]部分加入:skip-name-resolve,保存文件,重啟mysql,一切OK啦,速度象飛一樣了

新版本的mysql配置起來不象以前的那個傻瓜化了,這個問題折騰了我一上午的時間,晚上回來總算是解決了,嘿嘿,又學到一些東西。

Windows 2003下的MySQL 5服務器,本機連接到MySQL服務非常快,局域網內有兩臺Linux機器,有一臺連接很快,另外一臺輸入密碼后要等好幾秒鐘才能連上。

解決辦法:

在MySQL服務器的配置中增加一個如下配置后速度飛快。

[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遠程連接MYSQL速度慢,有時遠程連接到MYSQL用時4-20秒不等,本地連接MYSQL正常,出現這種問題的主要原因是,默認安裝的MYSQL開啟了DNS的反向解析,在MY.INI(WINDOWS系統下)或MY.CNF(UNIX或LINUX系統下)文件的[mysqld]下加入skip-name-resolve這一句。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 蕲春县| 萍乡市| 双鸭山市| 曲靖市| 全椒县| 女性| 阜新| 静乐县| 四川省| 泗阳县| 湘阴县| 嘉荫县| 新竹县| 宜宾市| 密山市| 乌拉特后旗| 如皋市| 弋阳县| 杭锦旗| 白朗县| 旌德县| 栾川县| 石景山区| 佛冈县| 五台县| 原平市| 抚顺县| 宁阳县| 浏阳市| 凭祥市| 湘潭县| 壶关县| 苏尼特左旗| 鄂伦春自治旗| 华容县| 民和| 白河县| 阳朔县| 波密县| 山阳县| 敦煌市|