Bug #52434 [Bgs]: mysqlnd: host cannot be "localhost" when connecting to tcp port
| From: | pajoye@php.net | Date: | Thu, 16 Sep 2010 21:30:01 +0000 |
| Subject: | Bug #52434 [Bgs]: mysqlnd: host cannot be "localhost" when connecting to tcp port | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-154439@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=52434&edit=1
ID: 52434
Updated by: pajoye@php.net
Reported by: anthon dot pang at gmail dot com
Summary: mysqlnd: host cannot be "localhost" when connecting
to tcp port
Status: Bogus
Type: Bug
Package: MySQL related
Operating System: Ubuntu 10.04
PHP Version: 5.3.3
Block user comment: N
New Comment:
There are dozen of reports about that on Windows and it is unrelated to
this problem.
A work around for the windows issue will be present in 5.3.4, in the
meantime you can disable ::1 in your windows' host file.
Previous Comments:
------------------------------------------------------------------------
[2010-09-16 23:01:03] neweracracker at gmail dot com
Hello.
I am able to reproduce this issue with:
Windows 7 build 7600 (Ultimate Edition) x86
PHP Version 5.3.3 MSVC6
mysqlnd 5.0.7-dev - 091210 - $Revision: 300533 $
MySQL 5.1.50
Steps to reproduce:
1. Download phpmyadmin
2. Extract on html/www/public_html (or similar)
3. Try to connect to mysql (example: login)
4. It won't work, stop php
5. Edit config.inc.php and change localhost to 127.0.0.1
6. No more errors. I guess this needs a fix
------------------------------------------------------------------------
[2010-07-25 19:00:49] anthon dot pang at gmail dot com
Ok. I'll open a Documentation bug for this compat buster.
------------------------------------------------------------------------
[2010-07-25 18:33:43] johannes@php.net
The patch won't be added as then "localhost" has two meanings - one time
meaning "use the unixdomain socket in the default location" and one time
actually "resolve localhost and use TCP" as it is taught in many places
that "localhost" in MySQL has the first meaning we keep it there.
------------------------------------------------------------------------
[2010-07-25 09:05:29] anthon dot pang at gmail dot com
Seriously?
http://www.php.net/manual/en/ref.pdo-mysql.connection.php
gives two
examples:
mysql:host=localhost;port=3307;dbname=testdb
mysql:unix_socket=/tmp/mysql.sock;dbname=testdb
And my DSN (constructed by Zend Framework) follows the first example.
Where does it say I have to define the unix socket in php.ini if I
intend to connect using the tcp port?
Here's the fix:
--- mysqlnd.c.bak 2010-07-25 02:47:29.000000000 -0400
+++ mysqlnd.c 2010-07-25 02:49:37.000000000 -0400
@@ -635,7 +635,7 @@
char * transport = NULL;
int transport_len;
#ifndef PHP_WIN32
- if (host_len == sizeof("localhost") - 1 &&
!strncasecmp(host, "localhost", host_len)) {
+ if (!port && host_len == sizeof("localhost") - 1 &&
!strncasecmp(host, "localhost", host_len)) {
DBG_INF_FMT("socket=%s", socket? socket:"n/a");
if (!socket) {
socket = "/tmp/mysql.sock";
------------------------------------------------------------------------
[2010-07-25 06:31:41] dtajchreber@php.net
Tell PHP where your mysql.sock file is via the DSN or
pdo_mysql.default_socket in
the php.ini file and your error will go away. Your conclusion is way
off.
http://www.php.net/manual/en/ref.pdo-mysql.connection.php
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/bug.php?id=52434
--
Edit this bug report at http://bugs.php.net/bug.php?id=52434&edit=1