Why does PHP PDO get "SQLSTATE [42000] [1044] Access is denied for user" when mysql command line is running?

My head is bloody from how hard I hit her against this wall in the last few hours. :(

As the name implies, I created a MySQL user who can access the database in the mysql command line on the database server. However, when I try to instantiate a new PDO to access the database with the same user, I get:

SQLSTATE[42000] [1044] Access denied for user 'bob'@'localhost' to database 'my_database'

This is how I created the user:

GRANT SELECT, DELETE, EXECUTE, INSERT, UPDATE ON my_database.* TO 'bob'@'localhost' IDENTIFIED BY 'some_password';

What could be the problem? Please, someone threw a bone to me! (FYI, the problem occurs when I try to create a new PDO ... I will catch a PDOException and this message).

I did FLUSH PRIVILEGES after the grant, and here is the SHOW GRANTS performance:

mysql> SHOW GRANTS FOR 'bob'@'localhost';
+------------------------------------------------------------------------------------------------------------+
| Grants for bob@localhost                                                                                   |
+------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'bob'@'localhost' IDENTIFIED BY PASSWORD '.........................................' |
| GRANT SELECT, INSERT, UPDATE, DELETE, EXECUTE ON `my_database`.* TO 'bob'@'localhost'                      |
+------------------------------------------------------------------------------------------------------------+

mysql.db :

mysql> SELECT * FROM db WHERE User = 'bob'\G;
*************************** 1. row ***************************
                 Host: localhost
                   Db: my_database
                 User: bob
          Select_priv: Y
          Insert_priv: Y
          Update_priv: Y
          Delete_priv: Y
          Create_priv: N
            Drop_priv: N
           Grant_priv: N
      References_priv: N
           Index_priv: N
           Alter_priv: N
Create_tmp_table_priv: N
     Lock_tables_priv: N
     Create_view_priv: N
       Show_view_priv: N
  Create_routine_priv: N
   Alter_routine_priv: N
         Execute_priv: Y
           Event_priv: N
         Trigger_priv: N

, , node MySQL, Ubuntu 12.04 LTS.

EDIT: , Zend AMF. , PDO Zend AMF? , - Zend AMF?

+5
2

'bob'@'127.0.0.1' . php 127.0.0.1, "localhost", DNS , MySQL .

+5

Googlers , , . , , , .

, , , $ .

$ , , ,

$pass = 'randomchars$morerandom';

,

$pass = "randomchars$morerandom";
+3

All Articles