MySQL Forums
Forum List  »  Newbie

error 2002 (connection attempt failed)
Posted by: Jeremy Canfield
Date: September 11, 2014 06:17PM

My apologies for the noobie question here. I’ve spent many hours trying to figure this out, but I just can’t seem to figure it out. I’m new to MySQL. I’ve setup a LAN webpage with simple PHP that will connect to MySQL: www.jeremyjcanfield.com/musictable1_lan.php. MySQL Server is running on my computer 192.168.0.10. Using a different computer in my LAN, 192.168.0.101, I go to www.jeremyjcanfield.com/musictable1_lan.php, and get error 2002 (connection attempt failed). If I log into MySQL Workbench, and go to Server Status, the server status is Running. I’ve turned off windows firewall on both 192.168.0.10 and 192.168.0.101. I’ve put my router into DMZ, so that it doesn’t use a firewall and processes all traffic, so I should be able to have traffic on port 3306. These computers in my LAN are on the same subnet. Both computers are Windows 7.

If it helps, I also set up a WAN webpage, so that remote users will be able to connect to MySQL server through the PHP over the internet, here: www.jeremyjcanfield.com/musictable1_wan.php.

Here is the PHP code I’m using:

<?php

$hostname="192.168.0.10";
$username="root";
$password="here I have my correct password";
$database="test1";

$link = mysql_connect($hostname, $username, $password, $database);
if (!$link) {
die('Connection failed: ' . mysql_error());
}

?>

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.