FIX: SQLSTATE[HY000] [1045] Access denied for user ‘root’@’localhost’ (using password: NO)

Error:

SQLSTATE[HY000] [1045] Access denied for user ‘root’@’localhost’ (using password: NO)

image

Scenario:

After very first setup of your own wamp/xamp with MySQL DB and updated password for DB root user, you notice that your php code fails to connect/communicate to the mySQL DB with above error.

 

CAUSE and FIX:

This error message indicates that you are attempting to connect/logon to the MySQL with reported user “root” without specifying any password or it’s password value is NULL.

 

To fix it, you need to provide the appropriate root user password for on your MySQL DB connection string or call.

 

Many of the newbie’s, usually encounter this case/scenario whenever they have a project that contains the DB connection string details saved in a global config file like Config.php.

image

 

<

p>Once you set the right password in Config.php file, then the pages starts loading fine and updates to DB flows through.

Leave a Reply

Your email address will not be published. Required fields are marked *