Bug #67026 [NEW]: 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:16:22 +0000 |
| Subject: | Bug #67026 [NEW]: PDO on Windows ignores username when password is empty and username is not root | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-185099@lists.php.net to get a copy of this message | ||
From: unirgy at gmail dot com
Operating system: Windows
PHP version: 5.5.11
Package: PDO MySQL
Bug Type: Bug
Bug description:PDO on Windows ignores username when password is empty and username is not root
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 bug report at https://bugs.php.net/bug.php?id=67026&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=67026&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=67026&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=67026&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=67026&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=67026&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=67026&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=67026&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=67026&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=67026&r=support
Expected behavior: https://bugs.php.net/fix.php?id=67026&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=67026&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=67026&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=67026&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=67026&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=67026&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=67026&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=67026&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=67026&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=67026&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=67026&r=mysqlcfg