Solved: Error “Access denied for user ‘root’@’localhost’” of MySql — codementor.tech
This is just a summary. For full specification please refer to THIS link.
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.
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;
After all this, you need to type exit again.
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.
If you want to install a fresh installation simply go through this LINK.