Edit report at http://bugs.php.net/bug.php?id=45468&edit=1

 ID:               45468
 Comment by:       wolfgang_weber at gmx dot at
 Reported by:      michael dot kofler at gmx dot com
 Summary:          Using mysqlnd defaults to using unix socket instead of
                   localhost:port
 Status:           Closed
 Type:             Bug
 Package:          MySQL related
 Operating System: * (not win32)
 PHP Version:      5.3CVS, 6CVS (2009-04-25)
 Assigned To:      johannes

 New Comment:

I don't know why this ticket has been closed as I am still affected from
this bug.



PHP: 5.3.2 with mysqlnd and php-fpm patch from svn

MySQL: 5.1.46

OS: Centos 5.4 x86_64



Configure options:



--with-mysql=mysqlnd \

--with-mysqli=mysqlnd \

--with-mysql-sock=/var/lib/mysql \



Tried to add a zone in ZoneAdmin, and this is a part from my error log:



[06-May-2010 12:08:39] PHP Warning:  mysql_connect(): [2002] No such
file or directory (trying to connect via unix:///tmp/mysql.sock) in
/var/www/tools/zoneadmin/includes/config.php on line 28



So why do you think that this is not a bug anymore?



Kind regards

Wolfgang Weber


Previous Comments:
------------------------------------------------------------------------
[2009-08-27 10:35:27] and...@php.net

Closing this, as not a bug anymore

------------------------------------------------------------------------
[2009-08-27 10:26:20] and...@php.net

Jani,

I think you are wrong :

and...@winnie:/work/vanilla/php/php-src/branches/PHP_5_3$ ./php -r
'$c=mysql_connect("localhost:3307");var_dump($c,
$res=mysql_query("select 42", $c), mysql_fetch_assoc($res));'



Warning: mysql_connect(): Can't connect to local MySQL server through
socket '/var/run/mysqld/mysqld.sock' (2) in Command line code on line 1



Warning: mysql_query() expects parameter 2 to be resource, boolean given
in Command line code on line 1



Warning: mysql_fetch_assoc() expects parameter 1 to be resource, null
given in Command line code on line 1

bool(false)

NULL

NULL

---------------------------

My MySQL runs on 3307 and the socket it uses is /tmp/mysql.sock. I have
a /etc/my.cnf, that specifies /var/run/mysqld/mysqld.sock, and the
client tries to use it. So you see, if you specify localhost this means
- use unix socket, no matter if there is a port or not. mysqlnd does the
same. Same is valid if you try mysql --host localhost --port=3307 . I
suppose in your case you had mysql running with socket which you was
where expected.



------------------------------------------------------------------------
[2009-04-26 15:27:11] j...@php.net

This is clearly a bug:



# sapi/cli/php -n -r 'mysql_connect("localhost:3306");'



Output with --with-mysql=mysqlnd:



Warning: mysql_connect(): [2002] No such file or directory (trying to 

connect via unix:///tmp/mysql.sock) in Command line code on line 1



# sapi/cli/php -n -r 'mysql_connect("localhost:3306");'



No output (error) --with-mysql (without mysqlnd) -> connection works.



The problem is with code in ext/mysqlnd/mysqlnd.c:537-543 which forces 

using the socket in this case.



Note: Same happens with mysqli. This bug also makes all mysql(i) tests 


fail unless one uses some environment variables while running them.



------------------------------------------------------------------------
[2009-02-03 11:59:28] and...@php.net

 Hi,

it was a problem, the Unix path, in the extensions, not mysqlnd. Yes,
mysqlnd uses /tmp/mysql.sock, but actually there are no configure
options for mysqlnd. --with-mysql-sock is actually an option of
ext/mysql . It wasn't used in the past, as far as I recall, but current
5_3 and HEAD do use it to set default value for the socket path, which
can be overwritten by the user. Both for ext/mysql and mysqli.

This if from ext/mysql/php_mysql.c :

#ifdef MYSQL_UNIX_ADDR

        STD_PHP_INI_ENTRY("mysql.default_socket",               
MYSQL_UNIX_ADDR,PHP_INI_ALL,OnUpdateStringUnempty,      default_socket, 
zend_mysql_globals,             mysql_globals)

#else

        STD_PHP_INI_ENTRY("mysql.default_socket",               NULL,   
PHP_INI_ALL,            OnUpdateStringUnempty,  default_socket, 
zend_mysql_globals,             mysql_globals)

#endif





This is from ext/mysqli/mysql.c :

#ifdef PHP_MYSQL_UNIX_SOCK_ADDR

        STD_PHP_INI_ENTRY("mysqli.default_socket",                      
MYSQL_UNIX_ADDR,PHP_INI_ALL,OnUpdateStringUnempty,      default_socket, 
zend_mysqli_globals,            mysqli_globals)

#else

        STD_PHP_INI_ENTRY("mysqli.default_socket",                      NULL,   
PHP_INI_ALL,            OnUpdateStringUnempty,  default_socket, 
zend_mysqli_globals,            mysqli_globals)

#endif



MYSQL_UNIX_ADDR is a macro, for PHP_MYSQL_UNIX_ADDR, which is defined by
the configure script if --with-mysql-sock is used.



In this regard, PDO doesn't use --with-mysql-sock. PDO_MYSQL used
mysql_config to find the socket, but for mysqln defaults to
/tmp/mysql.sock , which seems like bug, because of inconsistency.

This is something for Johannes



Best,

Andrey

------------------------------------------------------------------------
[2009-02-03 11:43:38] johan...@php.net

Please try using this CVS snapshot:

  http://snaps.php.net/php5.3-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/

--with-mysql-sock should work now properly

------------------------------------------------------------------------


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=45468


-- 
Edit this bug report at http://bugs.php.net/bug.php?id=45468&edit=1

Reply via email to