note 94316 modified in function.mysql-connect by danbrown
| From: | danbrown@php.net | Date: | Thu, 29 Oct 2009 15:12:45 +0000 |
| Subject: | note 94316 modified in function.mysql-connect by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-162254@lists.php.net to get a copy of this message | ||
On Windows Vista or above, an entry in the Windows/System32/drivers/etc/hosts file causes
mysql_connect() connections to "localhost" to timeout and never connect. This happens on
php 5.3 and above since it now uses mysql native driver which has changed it connection behavior
compared to libmysql.dll in previous versions. It is not a PHP bug, but definitely a configuration
issue for users on new windows systems.
To get around this, you must remove the entry like this:
::1 localhost
and make sure you still have:
127.0.0.1 localhost
Also, you could change the code to connect to the ip instead, but that is inconvenient if you have
many web sites.
This issue occurs on Windows Vista, Windows 7 and Windows Server 2008.
--was--
On Windows Vista or above, an entry in the Windows/System32/drivers/etc/hosts file causes
mysql_connect() connections to "localhost" to timeout and never connect. This happens on
php 5.3 and above since it now uses mysql native driver which has changed it connection behavior
compared to libmysql.dll in previous versions. It is not a PHP bug, but definitely a configuration
issue for users on new windows systems.
To get around this, you must remove the entry like this:
::1 localhost
and make sure you still have:
127.0.0.1 localhost
Also, you could change the code to connect to the ip instead, but that is inconvenient if you have
many web sites.
I lost MANY hours on this small change and found the answer in a closed PHP report that was kind of
ignored. PHP Team: Perhaps this should be in the windows installation manual?
This issue occurs on Windows Vista, Windows 7 and Windows Server 2008.
http://php.net/manual/en/function.mysql-connect.php