Edit report at https://bugs.php.net/bug.php?id=43812&edit=1
ID: 43812
Comment by: ben at redsnapper dot net
Reported by: graced at wingsnw dot com
Summary: 'password' parameter in my.cnf not honored even with
mysqli_options()
Status: No Feedback
Type: Bug
Package: MySQLi related
Operating System: Debian lenny/sid
PHP Version: 5.2.5
Assigned To: andrey
Block user comment: N
Private report: N
New Comment:
This problem is reproducible and has nothing to do with the read-status of the my.cnf files. We are
seeing username,host,database all being set by the my.cnf file - but not the password value.
mysqli_real_connect(): (28000/1045): Access denied for user
'special_u'@'101.202.185.245' (using password: NO)
We have tested the same file using mysql --defaults-extra-file=my.cnf with no problems.
Previous Comments:
------------------------------------------------------------------------
[2009-07-27 06:36:23] axz55 at case dot edu
Also able to reproduce this using PHP 5.3.0
Verified that the username is being read from the file but the password is not. The file permissions
are 0400 and the mysql command line client reads the file just fine.
------------------------------------------------------------------------
[2008-07-22 01:00:01] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
------------------------------------------------------------------------
[2008-07-14 20:28:38] uw@php.net
I can't reproduce this with PHP 5.3 CVS nor with PHP 5.2.6, please check the notes on http://dev.mysql.com/doc/refman/5.1/en/option-files.html,
e.g. "On Unix platforms, MySQL ignores configuration files that are world-writable. This is
intentional as a security measure."
------------------------------------------------------------------------
[2008-01-15 05:03:13] graced at wingsnw dot com
Clarification:
Warning: mysqli::real_connect(): (28000/1045): Access denied for user
'wadmin'@'localhost' (using password: NO) in /home/.../- on line 6
'wadmin' was the username I was connecting with (I missed it when sanitizing my.cnf
values), NOT my current login name (which is what PHP and mysql both default to otherwise).
Just in case it matters.
------------------------------------------------------------------------
[2008-01-11 03:32:02] graced at wingsnw dot com
Description:
------------
my.cnf files allow the username/password/hostname and other connection information to be stored for
later use.
The Mysqli extension accepts a username from the file (overriding the default of the current login
username) but not a password, thus it attempts to connect with no password even when a password is
specified. The mysql command line client, when pointed at the file using
--defaults-extra-file=path/to/file.cnf, successfully connects.
Reproduce code:
---------------
my.cnf contents:
[client]
host = localhost
user = "username"
password = "topsecret"
PHP script:
<?php
error_reporting(E_ALL);
$DB = mysqli_init();
$DB->options(MYSQLI_READ_DEFAULT_FILE, "my.cnf");
$DB->options(MYSQLI_READ_DEFAULT_GROUP, "client");
$DB->real_connect();
Expected result:
----------------
A successful database connection.
Actual result:
--------------
Warning: mysqli::real_connect(): (28000/1045): Access denied for user
'wadmin'@'localhost' (using password: NO) in /home/.../- on line 6
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=43812&edit=1