Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy does PHP PDO get "SQLSTATE[42000] [1044] Access denied for user" when mysql command line works?
    primarykey
    data
    text
    <p>My head is bloody from how hard I've been banging it against this wall for the past several hours. :(</p> <p>As the title suggests, I've created a MySQL user that can access the database <em>fine</em> from the mysql command prompt on the database server. However, when I try to instantiate a new PDO object to access the database with that same user, I get:</p> <pre><code>SQLSTATE[42000] [1044] Access denied for user 'bob'@'localhost' to database 'my_database' </code></pre> <p>Here's how I created the user:</p> <pre><code>GRANT SELECT, DELETE, EXECUTE, INSERT, UPDATE ON my_database.* TO 'bob'@'localhost' IDENTIFIED BY 'some_password'; </code></pre> <p>What could be the problem here?! Please someone throw me a bone! (FYI, the problem happens when I try to create a new PDO object...I catch a PDOException and that's the message).</p> <p>I did FLUSH PRIVILEGES after the grant, and here's the output of SHOW GRANTS:</p> <pre><code>mysql&gt; 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' | +------------------------------------------------------------------------------------------------------------+ </code></pre> <p>And here's what mysql.db looks like for this user:</p> <pre><code>mysql&gt; 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 </code></pre> <p>In case it matters, this is a four-node MySQL cluster running on Ubuntu 12.04 LTS.</p> <p>EDIT: I've discovered that the problem only occurs when I try to access the server using Zend AMF. Any ideas why PDO wouldn't work with Zend AMF? Have I perhaps missed something in my Zend AMF setup?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload