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

In this article, we will solution for below error.

>MySQL ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

Solution:

The correct way is to login to MySQL with sudo privilege.

sudo mysql -u root -p

And then updating the password using:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'new-password';

Once this is done stop and start the MySQL server.

sudo service mysql stop sudo service mysql start