From: subscription at nazarenko dot net
Operating system: Linux SuSE 8.2
PHP version: 5.0.3
PHP Bug Type: MySQLi related
Bug description: Setting mysqli.default_socket in php.ini has no effect
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 bug report at http://bugs.php.net/?id=32081&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=32081&r=trysnapshot4
Try a CVS snapshot (php5.0):
http://bugs.php.net/fix.php?id=32081&r=trysnapshot50
Try a CVS snapshot (php5.1):
http://bugs.php.net/fix.php?id=32081&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=32081&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=32081&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=32081&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=32081&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=32081&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=32081&r=support
Expected behavior: http://bugs.php.net/fix.php?id=32081&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=32081&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=32081&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=32081&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=32081&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=32081&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=32081&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=32081&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=32081&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=32081&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=32081&r=mysqlcfg