php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51759 Same as bug #45150 (localhost -> 127.0.0.1)
Submitted: 2010-05-06 21:43 UTC Modified: 2013-02-18 00:34 UTC
Votes:9
Avg. Score:5.0 ± 0.0
Reproduced:9 of 9 (100.0%)
Same Version:8 (88.9%)
Same OS:3 (33.3%)
From: sed at sed dot is Assigned:
Status: No Feedback Package: MySQL related
PHP Version: 5.3.2 OS: Windows 7 Ultimate 64bit
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
27 + 3 = ?
Subscribe to this entry?

 
 [2010-05-06 21:43 UTC] sed at sed dot is
Description:
------------
Same as bug #45150. I was not able to connect to MySQL via localhost though PHP found the mysql extension etc.
Finally, after 20 hours work, I found a website through Google that let me to a solution. To fix this I'll have to use "127.0.0.1" instead of "localhost"
I'm using IIS7.5 on Windows 7 Ultimate 64bit
FastCGI (PHP 5.2.13 installer [20,929Kb] - 25 February 2010, md5: 891e3262428851ebe71d5432a97be6d5, with my own php.ini aftertouch)
MySQL 5.1.46-winx64
Using both IPv4 and IPv6
I can use localhost within MySQL command prompt, but not with PHP.

Test script:
---------------
// timeout
$host = "localhost";
$user = "root";
$password = "******";
$database = "******";
$mysql_link = mysql_connect( $host, $user, $password );

// timeout fixed
$host = "127.0.0.1";
$user = "root";
$password = "******";
$database = "******";
$mysql_link = mysql_connect( $host, $user, $password );


Expected result:
----------------
Normal connection with mysql without timeout.

Actual result:
--------------
Timeout trying to connect via mysql_connect (Error: 2002)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-05-09 17:46 UTC] falcon_ia at hotmail dot com
After I updated php from 5.3.0 to 5.3.2,
mysql_connect cannot connect localhost but 127.0.0.1.
It shows:
Warning: mysql_connect() [function.mysql-connect]: [2002] A connection attempt failed because the connected party did not (trying to connect via tcp://localhost:3306) in ........

And drivers\etc\hosts seems good.
 [2010-06-27 13:43 UTC] therealloonylion at yahoo dot co dot uk
I have the same issue as falcon_ia at hotmail dot com. I upgraded 5.3.0 to 5.3.2 and php is no longer able to connect to Mysql. Mysql is working fine and my hosts file is correct.
 [2010-07-06 19:09 UTC] andrey@php.net
-Status: Open +Status: Feedback
 [2010-07-06 19:09 UTC] andrey@php.net
Check if this is your case, most probably it is.

http://blogs.iis.net/donraman/archive/2010/06/11/php-5-3-and-mysql-connectivity-problem.aspx
 [2013-02-18 00:34 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 22:01:28 2024 UTC