亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

Windows Server 2008 R2和2012中PHP連接MySQL過(guò)慢的解決方法

 更新時(shí)間:2016年07月02日 18:13:39   作者:eechen  
這篇文章主要介紹了Windows Server 2008 R2和2012中PHP連接MySQL過(guò)慢的解決方法,同時(shí)對(duì)Windows 7和8的本地開(kāi)發(fā)環(huán)境也有效,需要的朋友可以參考下

對(duì)比下面兩個(gè)腳本的速度:

  • Windows 7 用 localhost 連接本地 MySQL,速度會(huì)很慢。
  • Windows 7 用 127.0.0.1 連接本地 MySQL,速度則是正常的。

my.ini里配置了

bind-address=127.0.0.1

 用localhost連接本地MySQL: 速度慢

<?php
$start = microtime(true);
$mysqli = new mysqli('127.0.0.1', 'root', '', 'mysql'); //連接耗時(shí)僅為0.0025秒.
//$mysqli = new mysqli('localhost', 'root', '', 'mysql'); //連接耗時(shí)超過(guò)1秒,比正常慢了400倍.
echo microtime(true) - $start;

分析:
1.my.ini里配置

bind-address=127.0.0.1

時(shí),Win7及其以上版本系統(tǒng)PHP用localhost連接MySQL耗時(shí)超過(guò)1秒,比用127.0.0.1連接慢了400倍.
2.my.ini里配置

bind-address=::1

時(shí),Win7及其以上版本系統(tǒng)PHP用localhost連接MySQL速度是正常的,但用127.0.0.1連接又不正常了.
3.去掉bind-address配置,則用localhost或127.0.0.1連接MySQL速度都是正常的.

所以:在配置了

bind-address=127.0.0.1 

的情況下,應(yīng)該使用 127.0.0.1 連接本地 MySQL 數(shù)據(jù)庫(kù) 。
安裝 WordPress、phpMyAdmin 等 PHP 程序的時(shí)候默認(rèn)使用 localhost 連接本地 MySQL 數(shù)據(jù)庫(kù),這時(shí)注意把默認(rèn)的 localhost 改為 127.0.0.1。

另外,Windows 2008、2012 跟 Windows 7 存在同樣的問(wèn)題。

相關(guān)文章

最新評(píng)論