1045 – Access denied for user ‘root’@’localhost’ (using password: YES)

While dealing with phpMyAdmin for novice user, sometime you unable to login into mysql using the mysql console. It throws #1045 - Access denied for user 'root'@'localhost' (using password: YES) error on screen.

If root@localhost wasn't granted the necessary rights to access the database or you provided the wrong password, you will then encounter this error.

there might be multiple reason back to produce such an error on screen,. i.e you might be done some small changes in config.inc.php.  here we are going to solve this problem using following step:

  1. Open your command prompt console and type mysql -u root -p and press Enter.
  2. Update the MySql user table and reset the password as you wanted. for that type UPDATE mysql.user SET Password=PASSWORD('root') WHERE User='root'.
  3. Flush the privileges using following command: FLUSH PRIVILEGES;
  4. Exit by typing: Exit
  5. Edited line in the file config.inc.php with the new root password: $cfg['Servers'][$i]['password'] = 'root';

and that's done;

🙂