MySQL Error: : ‘Access denied for user ‘root’@’localhost’

Today, I am 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.

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.
Happy Coding!

(Visited 92 times, 1 visits today)

Leave a comment

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