简体   繁体   English

PHP(5.5.7)警告在Windows Servers 2008 R2中连接到MySQLi

[英]PHP (5.5.7) Warning connecting to MySQLi in Windows Servers 2008 R2

I'm running Moodle on PHP 5.5.7 64bit nts on Windows Server 2008 R2 with MySQL 5.5.36. 我在带有MySQL 5.5.36的Windows Server 2008 R2上的PHP 5.5.7 64位nts上运行Moodle。

Up until two days ago, there were no problems. 直到两天前,都没有问题。 To deal with Xdebugger being such a memory hog, an extra CPU and more memory was assigned to the virtual machine. 为了应对Xdebugger这样的内存消耗,虚拟机分配了额外的CPU和更多的内存。 The Windows license was also activated. Windows许可证也已激活。 The entire vm was rebooted. 整个虚拟机重新启动。 (I had restarted the machine before prior to this, with no problems). (在此之前,我已经重启了机器,没有任何问题)。

I am now receiving the following warning when I access any page on the site: 现在,当我访问网站上的任何页面时,都会收到以下警告:

    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

I created a test php page that simply consists of the following: 我创建了一个包含以下内容的测试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();

I receive the following output: 我收到以下输出:

    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

I have checked that "127.0.0.1 localhost" exists in my hosts file and that the IPv6 "::1" line has been commented out. 我检查了我的主机文件中是否存在“ 127.0.0.1 localhost”,并且IPv6的“ :: 1”行已被注释掉。 I have also attempted to use "localhost" but same problem. 我也曾尝试使用“ localhost”,但存在相同的问题。

The bizarre thing is that if I refresh the page, occasionally, and completely at random, the warning doesn't occur and the correct output is given. 奇怪的是,如果我偶尔且完全随机地刷新页面,则不会发生警告,并且会给出正确的输出。

I have attempted to disable the warnings, but php appears to be ignoring me. 我试图禁用警告,但是php似乎无视我。 Also, disabling the warning is not exactly ideal. 同样,禁用警告也不是理想的选择。

Any ideas? 有任何想法吗?

EDIT: 编辑:

So after much pain staking back and forths between PHP and MySQL and IIS, it looks like (once again) it was php.ini to blame. 因此,在PHP与MySQL和IIS之间来回费尽心血之后,看起来(再次)是php.ini的原因。

To be honest, I cant even tell you which setting was the problem - but I changed all possible timeout related settings in php.ini to a large number (10000 or -1 depending on the setting), as well as the connection_timeout for mysql in my.ini. 老实说,我什至无法告诉您问题出在哪个设置上-但我将php.ini中所有可能的与超时相关的设置更改为一个大数字(10000或-1,具体取决于设置),以及mysql中的connection_timeout my.ini。

I am still yet to figure out which one was causing the problem, but will edit this post if I ever do. 我仍未弄清楚是谁引起了这个问题,但是如果我愿意的话,会编辑这篇文章。

So after much pain staking back and forths between PHP and MySQL and IIS, it looks like (once again) it was php.ini to blame. 因此,在PHP与MySQL和IIS之间来回费尽心血之后,看起来(再次)是php.ini的原因。

To be honest, I cant even tell you which setting was the problem - but I changed all possible timeout related settings in php.ini to a large number (10000 or -1 depending on the setting), as well as the connection_timeout for mysql in my.ini. 老实说,我什至无法告诉您问题出在哪个设置上-但我将php.ini中所有可能的与超时相关的设置更改为一个大数字(10000或-1,具体取决于设置),以及mysql中的connection_timeout my.ini。

I am still yet to figure out which one was causing the problem, but will edit this post if I ever do. 我仍未弄清楚是谁引起了这个问题,但是如果我愿意的话,会编辑这篇文章。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM