php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #50172 Unable to communicate with the MySQL server service
Submitted: 2009-11-13 21:38 UTC Modified: 2009-12-11 12:48 UTC
Votes:8
Avg. Score:4.6 ± 0.7
Reproduced:7 of 7 (100.0%)
Same Version:5 (71.4%)
Same OS:4 (57.1%)
From: erik at navhost dot com Assigned: mysql (profile)
Status: Not a bug Package: MySQL related
PHP Version: 5.3.1RC4 OS: win32 only - Win. Server 2008 R2
Private report: No CVE-ID: None
 [2009-11-13 21:38 UTC] erik at navhost dot com
Description:
------------
I've tried to find the solution for this issue here since last month, but if I install any of the recent 5.3 RCs, PHP simply will not talk to the MySQL service.

I upgraded from 5.2.10, and the problem was not present in that version. As far as I recall 5.3.0 and it's RCs did connect but had other issues later resolved.

When I reinstall 5.2.11, everything is back to normal.

I've reproduced this on 3 servers, all running Windows Server 2008.

Bottom line; 5.2.11 can connect and talk to the MySQL service, 5.3.1RC4 can not.

Reproduce code:
---------------
mysql_connect('localhost', 'root', '***');

Expected result:
----------------
Success!

Actual result:
--------------
(After 60 seconds)
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. 

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-11-13 21:57 UTC] pajoye@php.net
see the other bug report about IPv6 being enabled. Comment out the ::1 line in your hosts file and try again (see the other reports or google about it if you don't know what is it).
 [2009-11-13 22:18 UTC] erik at navhost dot com
Do you mean bug #48805? Anyway, that lin line is already commented out by an '#' in the server's hosts file. It was that way by default.
 [2009-11-14 04:06 UTC] erik at navhost dot com
I can't seem to find the report you're referring to, but the issue still stands. Is it a IPv6 related issue?

The ::1-line in the hosts file is already commented out.
 [2009-11-14 15:58 UTC] erik at navhost dot com
Looking into it further, the comment from pajoye fixes the issue in the vista-based Server 2008. However, Server 2008 R2 is based on Windows 7 and introduces a new feature on the resolving localhost... see from the hosts file:

"localhost name resolution is handled within DNS itself."

So I guess this is a windows bug rather than PHP? I can't see an easy solution here either way.
 [2009-11-14 16:39 UTC] pajoye@php.net
I mean Bug #45150. But it looks like you may have met another issue. Assigned to the mysql team so they can for more details.
 [2009-11-14 20:07 UTC] erik at navhost dot com
A simple workaround is to uncomment/add this line to the host file:
127.0.0.1        localhost

Worked for me.
 [2009-11-18 22:54 UTC] carsten_sttgt at gmx dot de
> So I guess this is a windows bug rather than PHP?

No, it's a bug in the PHP stream transport. (mysqlnd is using PHP streams for the connection)

-->
If PHP is asking the OS for the IP for the host "localhost", it gets a list with 2 addrinfo structures (one for ::1 and the other for 127.0.0.1), but PHP is only trying a connection to the first one. Well, the MySQL server don't know IPV6, and thus the connection fails.

Regards,
Carsten
 [2009-11-20 00:56 UTC] avivahl at gmail dot com
This bug still exists in the final 5.3.1 release. :-(
Reproduced here using Windows 7 w/ IIS 7.5 (FastCGI is used w/ Non-Thread-Safe php).
The workaround suggested by erik (editing hosts file) works for me.

Btw, PHP 5.3.0 (final) did not have this issue.
 [2009-11-20 13:14 UTC] ferd352+php at gmail dot com
I'm having the same issue, along with other problems, trying to upgrade from PHP 5.2 to 5.3 (VC9)

Just tried 5.3.1 on Win2k8_R2 IIS7.5 and I have to change "localhost" to "127.0.0.1" in my scripts even though the hosts file already has the entry 127.0.0.1
 [2009-11-20 13:20 UTC] ferd352+php at gmail dot com
Sorry, I seemed to miss the message above about commenting out the "::1" line, which when I did resolved the issue.
 [2009-11-22 18:36 UTC] dominique at ottello dot net
Problem only with 5.3.1. No problem with 5.3.0 final.
Regards
 [2009-12-08 09:45 UTC] mcleod at spaceweb dot nl
PHP 5.3.1 does not communicate with MySQL, not with PDO_MySQL through ZendFramework and not with old mysql_ family functions.
 [2009-12-11 12:48 UTC] pajoye@php.net
For the 1000th time, this is NOT a bug. 

Disable IPv6 or do the necessary changes in the hosts file (::1 and other).
 [2010-10-17 10:49 UTC] signals4change at yahoo dot com
edit this file with notepad:
C:\Windows\System32\drivers\etc\hosts

change
#       127.0.0.1       localhost
#	::1             localhost

to
127.0.0.1       localhost
#	::1             localhost
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Nov 24 03:01:32 2024 UTC