2014-02-26 72 views
0

我在MySQL 5.5.36上运行Windows Server 2008 R2上的PHP 5.5.7 64位nts上的Moodle。PHP(5.5.7)警告连接到Windows Server 2008 R2中的MySQLi

直到两天前,没有问题。为了处理Xdebugger这样一个内存管理器,一个额外的CPU和更多的内存被分配给虚拟机。 Windows许可证也被激活。整个虚拟机已重新启动。 (在此之前,我已经重新启动了机器,没有问题)。

我现在收到以下警告,当我访问该网站的任何页面:

PHP Warning: mysqli::mysqli(): (HY000/2002): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. 
    in C:\inetpub\wwwroot\moodle\lib\dml\mysqli_native_moodle_database.php on line 375 

我创建了一个测试PHP页面,简单地包括以下:

$mysqli = new mysqli("127.0.0.1", "moodleuser", 'xxxx', "moodle", 3306); 
    if ($result = $mysqli->query("SELECT * from mdl_user limit 10")) { 
     echo "Select returned $result->num_rows"; 
    } else { 
     echo "Error"; 
    } 
    $mysqli->close(); 

我收到以下输出:

PHP Warning: mysqli::mysqli(): (HY000/2002): A connection attempt failed because   the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.in C:\inetpub\wwwroot\moodle\info.php on line 17 
    PHP Warning: mysqli::query(): Couldn't fetch mysqli in C:\inetpub\wwwroot\moodle\info.php on line 18 
    PHP Warning: mysqli::close(): Couldn't fetch mysqli in C:\inetpub\wwwroot\moodle\info.php on line 24 

我检查了“127.0.0.1 localhost”存在于我的主机上s文件,并且IPv6“:: 1”行已被注释掉。 我也试图使用“本地主机”,但同样的问题。

奇怪的是,如果我刷新页面,偶尔和完全随机,警告不会发生,并给出正确的输出。

我试图禁用警告,但php似乎无视我。另外,禁用警告并不完全理想。

任何想法?

编辑:

这么多的痛苦跑马圈地回来的Forth PHP和MySQL和IIS之间后,它看起来像(再次)这是php.ini的罪魁祸首。老实说,我甚至不能告诉你哪个设置是问题 - 但我把php.ini中的所有可能的超时相关设置更改为大数(10000或-1取决于设置),以及mysql中的connection_timeout在my.ini中。

我还没弄清楚哪一个导致了这个问题,但是如果我曾经这样做过,我会编辑这篇文章。

回答

0

因此,在PHP和MySQL和IIS之间来回拖动之后,看起来(再一次)它是php.ini的责任。老实说,我甚至不能告诉你哪个设置是问题 - 但我把php.ini中的所有可能的超时相关设置更改为大数(10000或-1取决于设置),以及mysql中的connection_timeout在my.ini中。

我还没弄清楚哪一个导致了这个问题,但是如果我曾经这样做过,我会编辑这篇文章。