I’ve just installed PHP on my IIS webserver with MySQL. When I try to execute the following code I get an “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. (2002)” error.
$db = new mysqli(‘127.0.0.1’, ‘user’, ‘password’, ‘database’);
if ($db->connect_errno > 0) {
echo “Failed to connect to MySQL: (” . $db->connect_errno . ") " . $db->connect_error;
}
I’ve tried chaning the IP to localhost, I’ve added ::1 to hosts file, I’ve setup a user on MySQL for ‘user’@‘127.0.01’, I’ve tried the original mysql_connect command, I’ve tried PDO commands, all to no avail.
I can login to the MySQL server locally with CLI and the database is accessed remotely with no connection issues. The problem is only seen via PHP.
Any other suggestions would be greatly appreciated.
IIS 7.5
PHP 5.3.28
MySQL 5.0
phpinfo;
mysqli
MysqlI Support enabled
Client API library version mysqlnd 5.0.8-dev - 20102224 - $Id: 731e5b87ba42146a687c29995d2dfd8b4e40b325 $
Active Persistent Links 0
Inactive Persistent Links 0
Active Links 0
Directive Local Value Master Value
mysqli.allow_local_infile On On
mysqli.allow_persistent On On
mysqli.default_host no value no value
mysqli.default_port 3306 3306
mysqli.default_pw no value no value
mysqli.default_socket no value no value
mysqli.default_user no value no value
mysqli.max_links Unlimited Unlimited
mysqli.max_persistent Unlimited Unlimited
mysqli.reconnect Off Off