My magento 2 installation is working fine, but when I go to terminal and try to use any command, for example image resize, it is giving me following

SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES)

As noted, front end is working fine.

1 Answer 1


You are on localhost or on live server.

Using password:NO means you are trying to connect to mysql without password, so unless your database doesn't have a password, 

Or you didn't updated your password field in env.php

In Magento 2.0, the configuration is in the same directory (app/etc/) and the file is env.php. The file path is: 


In this file, a number of key things are set, including the database connection information:

'host' => 'localhost',
'dbname' => 'magento2database',
'username' => 'some-username',
'password' => 'some password here',
  • This is normally the cause - however this is happening to me with the correct details in env.php. Aug 15, 2017 at 9:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.