Bug #67026 [Com]: 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 09:02:03 +0000 |
| Subject: | Bug #67026 [Com]: 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-185105@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
Comment 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: Not a bug
Type: Bug
Package: PDO MySQL
PHP Version: 5.5.11
Block user comment: N
Private report: N
New Comment:
You're correct, the issue is with mysql: https://gist.github.com/sellvana/9989227
Previous Comments:
------------------------------------------------------------------------
[2014-04-05 07:35:37] pajoye@php.net
Definitively not a bug in php. PDO only passes the credentials over. It is also not windows specific
(no windows specific code in PDO).
IIRC, it works just fine here.
------------------------------------------------------------------------
[2014-04-05 06:42:43] unirgy at gmail dot com
I was able to reproduce the issue on linux as well, with 'myuser'@'%' without
password
------------------------------------------------------------------------
[2014-04-05 06:35:12] unirgy at gmail dot com
I've identified that it works correctly with 'myuser'@'localhost'. The
issue appears when the privileges are given to 'myuser'@'%'
------------------------------------------------------------------------
[2014-04-05 05:22:42] unirgy at gmail dot com
I see previous reports:
https://bugs.php.net/bug.php?id=43493
https://bugs.php.net/bug.php?id=46457
------------------------------------------------------------------------
[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