Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've just upgraded from Windows XP to Windows 7 (64 bit)

I was using EasyPHP 5.3.1 to develop my website, but since I've upgraded I can't get PHP to talk to MySQL.

Even the PHPMyAdmin page doesn't load.

I've tried installing the latest 64bit version of MySQL in place of the supplied version of MySQL, but that hasn't helped.

The queries just don't seem to reach MySQL.

I have verified that the DB for my database works by running mysql on the command line.

PHPMyAdmin doesn't display an error, just a blank page.

The error coming up from my website is:

Warning: PDO::__construct() [pdo.--construct]: [2002] A connection attempt failed because the connected party did not (trying to connect via tcp://localhost:3306) in E:\services\EasyPHP-5.3.1\www\IdeaWeb\classes\Security.inc on line 14

Fatal error: Maximum execution time of 60 seconds exceeded in E:\services\EasyPHP-5.3.1\www\IdeaWeb\classes\Security.inc on line 0

Does anyone know how to solve this? (i.e. get MySQL talking to PHP.)

share|improve this question

5 Answers 5

up vote 2 down vote accepted

OK. I didn't know this but 127.0.0.1 and localhost are not the same thing on Windows 7.

I did some deeper Googling and found this thread. Basically it says in order to use localhost you need to set it up in the hostfile to point to 127.0.0.1

share|improve this answer

How are you referring to the SQL service? By local machine name, "localhost", a DNS name that points to the machine, an IP address associated with a physical interface on the machine, 127.0.0.1, ... ?

If you are talking to the SQL service by anything that could look remotely external then the most likelt culprit is the Windows firewall blocking the access. This is a good thing (the firewall should block things by default, only allowing connections in if explicitly told to do so), you just need to tell it to let your SQL connections. I've not used Windows 7 so I can't tell you exactly how to do this (things have no doubt moved around between versions) but it shouldn't be difficult. Also, if you are using an externl name/address as the hostname for connections, try using something explicitly local (localhost, 127.0.0.1) instead.

As a temporary measure to prove that the firewall is what is stopping the connection before you dig in to make changes, turn it off completely for a minute and try again. If PHP->SQL qorks with the firewall off then your firewall config needs tweaking, if it still fails then the problem lies elsewhere.

share|improve this answer
    
Thanks for the idea. I have turned the firewall off, but I'm still getting the same result. MySQL is setup with default settings (for EasyPHP), and the connection is to localhost. –  Matt Ellen Feb 20 '10 at 20:36

go to there

"control panel >> System and Security >> Windows Firewall >> Allowed Programs or ..."

ok now check these options :

  1. BranchCache - Content Retrieval ( user http)
  2. """"""""""" - Hosted Cache Client ( user https)
  3. """"""""""" - hosted cache server ( user https )
  4. """"""""""" - peer discovery ( user wsd )

enjoy :D

share|improve this answer

All you need to do is edit the following file if you have an admin rights

c:\windows\system32\drivers\etc\hosts

by uncommenting the line that says

127.0.0.1 localhost 

Save and refresh your pages....

share|improve this answer

I had this problem.

This is what it should look like if you're having problems:

<?php
$connect = mysql_connect('127.0.0.1','root','');
?>

For more information on your MySQL database, right click the ePHP icon on your toolbar and click Admin... -> Then a new page should open and click manage mysql. Hope this helps.

share|improve this answer

protected by Diago Oct 16 '10 at 6:29

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.