Solved: Error “Access denied for user ‘root’@’localhost'” of MySql

Solved: Error “Access denied for user ‘root’@’localhost’” of MySql

“Solved: Error “Access denied for user ‘root’@’localhost’” of MySql”.

Today, We are going to solve one of the most common errors of MySql.

This solution does not need to drop any tables or no need to change any user permission. just two line of code and then you will able to login into MySql console.

Without wasting much time let’s jump into it.

Fast Solution :

Follow given steps.

~ sudo su

~ mysql -u root -p
*enter your password*

~ update mysql.user set plugin = 'mysql_native_password' where User='root';

~ FLUSH PRIVILEGES;

~ exit;

Detailed Solution :

First, you need to type below command in your terminal.

~ sudo su

Then it will ask for the password. enter your superuser password.

After that, you will see below the screen in your terminal.

Solved: Error “Access denied for user ‘root’@’localhost'” of MySql

Then, You just need to type or you can copy this and command in your terminal and press ENTER.

~ update mysql.user set plugin = 'mysql_native_password' where User='root';

After that, you need to FLUSH the PRIVILEGES.

~ FLUSH PRIVILEGES;
~ EXIT;

After all this, you need to type exit again.

~ exit;

Now, Simply enter a command in your terminal.

~ mysql -u root -p

It will ask for the password. Enter the password and hit ENTER and you will see successfully logged in into a console.

That’s It. If you want to install a fresh installation simply go through this LINK.

Chherss! Happy Coding!

Adam Brown
Please follow and like us:

Leave a Comment