ID:               32081
 Updated by:       [EMAIL PROTECTED]
 Reported By:      subscription at nazarenko dot net
-Status:           Open
+Status:           Closed
 Bug Type:         MySQLi related
 Operating System: Linux SuSE 8.2
 PHP Version:      5.0.3
 New Comment:

This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.




Previous Comments:
------------------------------------------------------------------------

[2005-02-23 15:53:33] subscription at nazarenko dot net

Description:
------------
I am running MySQL 4.1.10 and PHP 5.0.3.

By default, on SuSE MySQL uses "/var/lib/mysql/mysql.sock".
I changed the location of the MySQL socket to "/srv/mysql/mysql.sock"
in /etc/my.cnf and MySQL is fine with it.

In my php.ini I have set mysqli.default_socket to the new socket
"/srv/mysql/mysql.sock".

Reproduce code:
---------------
The code:

$mysqli = mysqli_init();
$mysqli->real_connect('localhost', SQL_LOGIN, SQL_PASSWD);

produces the following warning:

mysqli::real_connect(): Can't connect to local MySQL server through
socket '/var/lib/mysql/mysql.sock' (2) in /srv/www/htdocs/index.php on
line 10

Expected result:
----------------
Since the socket value was omitted, it is expected that PHP uses the
default sockeet value from the php.ini file.

The error shows that the default socket value for MySQLi is ignored by
PHP.

Actual result:
--------------
When I first run phpinfo() I got the following output:

Client API version       4.1.10
MYSQLI_SOCKET            /var/lib/mysql/mysql.sock
mysqli.default_socket    /srv/mysql/mysql.sock

This made 3 things clear:

1) mysqli.default_socket variable *IS* correctly read from php.ini
2) mysqli.default_socket variable is *IGNORED* by the PHP interpreter
3) there is some variable called MYSQLI_SOCKET which is still set to
the "old-default" socket

I searched in the header files of MySQL and found a file called
"/usr/include/mysql/mysql_version.h", which contained a line:

#define MYSQL_UNIX_ADDR   "/var/lib/mysql/mysql.sock"

I changed it to "/srv/mysql/mysql.sock" and recompiled PHP again.

This time phpinfo() gave the following output:

Client API version       4.1.10
MYSQLI_SOCKET            /srv/mysql/mysql.sock
mysqli.default_socket    /srv/mysql/mysql.sock

However, the problem was not gone!

mysqli_real_connect() was still trying to use the "hard-coded" (?)
value from MySQL server "/var/lib/mysql/mysql.sock".

Adding --with-mysql-sock=/srv/mysql/mysql.sock to the configure options
list did not help either. I guess this is by design as --with-mysql-sock
is not a MySQLi related option anyway.


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


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

Reply via email to