Bug #67026 [Opn]: PDO on Windows ignores username when password is empty and username is not root
| From: | unirgy at gmail dot com | Date: | Sat, 05 Apr 2014 05:22:43 +0000 |
| Subject: | Bug #67026 [Opn]: PDO on Windows ignores username when password is empty and username is not root | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-185100@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=67026&edit=1
ID: 67026
User updated by: unirgy at gmail dot com
Reported by: unirgy at gmail dot com
Summary: PDO on Windows ignores username when password is
empty and username is not root
Status: Open
Type: Bug
Package: PDO MySQL
Operating System: Windows
PHP Version: 5.5.11
Block user comment: N
Private report: N
New Comment:
I see previous reports:
https://bugs.php.net/bug.php?id=43493
https://bugs.php.net/bug.php?id=46457
Previous Comments:
------------------------------------------------------------------------
[2014-04-05 05:16:20] unirgy at gmail dot com
Description:
------------
When trying to connect to db with a user that is not 'root' and password is empty (user
has correct privileges to dbname) PDO throws exception:
SQLSTATE[HY000] [1044] Access denied for user ''@'localhost' to database
'mydb'
When the supplied username is 'root' and password is empty, the connect succeeds if the db
user has empty password, or throws a correct exception:
SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using
password: NO)
The issues has been reproduced on multiple installations with PHP version 5.3.8 and also Mac with
MAMP 3.0.3
I wasn't sure if it's a bug and posted on SE here as well: https://stackoverflow.com/questions/22876169/pdo-on-windows-ignores-host-name-and-username-when-password-is-empty
Test script:
---------------
<?php
$host = "localhost";
$dbname = "mydb";
$user = "myuser";
$pass = "";
try {
$DBH = new PDO("mysql:host={$host};dbname={$dbname};charset=utf8", $user, $pass);
} catch (Exception $e) {
echo $e->getMessage();
}
Expected result:
----------------
Connection succeeded or exception:
SQLSTATE[HY000] [1045] Access denied for user 'myuser'@'localhost' (using
password: NO)
Actual result:
--------------
SQLSTATE[HY000] [1044] Access denied for user ''@'localhost' to database
'mydb'
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=67026&edit=1