MySQL doesn't talk to PHP anymore

5,263

Solution 1

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

Solution 2

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:
5,263

Related videos on Youtube

Matt Ellen
Author by

Matt Ellen

I write software for kidneys.

Updated on September 17, 2022

Comments

  • Matt Ellen
    Matt Ellen almost 2 years

    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.)

  • Matt Ellen
    Matt Ellen over 14 years
    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.