MySQL Forums
Forum List  »  Newbie

Re: error 2002 (connection attempt failed)
Posted by: Jeremy Canfield
Date: September 13, 2014 09:15AM

Thanks again guys for the amazing support getting a noobie (me) squared away. Both my machines are Windows 7, and I've the firewalls turned off on both. I'm on a switched LAN, and there is no firewall in the switch.

I'm not running a web server in my LAN. The www.jeremyjcanfield.com domain and web server are in the www.1and1.com network.

Barry mentions that the web server is whom is using the username / password to access mysql, and that user@localhost is only applicable if web server and MySQL server are on the same machine in the LAN. Below is my PHP, with the credentials I'm using. I've tried the following hostnames in the PHP, and tried to connect from both the machine running MySQL and a machine not running MySQL in my LAN, and all fail to connect:

localhost
127.0.0.1
192.168.0.10 (this is the machine running MySQL)
192.168.0.101 (this is the machine not running MySQL)
74.208.253.192 (this is the web server of www.jeremyjcanfield.com)


<?php

$hostname="192.168.0.10";
$username="jeremy";
$password="mypasswordhere";
$database="test1";

//DO NOT EDIT BELOW THIS LINE
$link = mysql_connect($hostname, $username, $password, $database);
if (!$link) {
die('Connection failed: ' . mysql_error());
}

?>

This is the full error I get most of the time:

Warning: mysql_connect() [function.mysql-connect]: [2002] A connection attempt failed because the connected party did not (trying to connect via tcp://192.168.0.10:3306) in E:\kunden\homepage\43\d478262032\www\musictable1_lan.php on line 10

Warning: mysql_connect() [function.mysql-connect]: [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 E:\kunden\homepage\43\d478262032\www\musictable1_lan.php on line 10

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.