MySQL Error: : 'Access denied for user 'root'@'localhost'


$ ./mysqladmin -u root -p 'redacted'

Enter password:

mysqladmin: connect to the server at 'localhost' failed error:

'Access denied for user 'root'@'localhost' (using password: YES)'

How can I fix this?



Below are the steps to be followed to rectify the error:

You will need to start the My SQL server instance by using the --skip--grant--tables option which is included in the security setting. 
$ mysqld --skip-grant-tables

Perform the execution of the below statements:
$ mysql -u root mysql

$mysql> UPDATE user SET Password=PASSWORD('my_password') where USER='root';


If you come across any error that states unknown field password, then use this:
update user set authentication_string=password('my_password') where user='root';

Restart the instance/daemon without using the --skip--grant--tables option.
$ /etc/init.d/mysql restart

You should now be able to connect with the new password.

$ mysql -u root -p

Enter the password: my_password


If you want to unleash your potential in this competitive field, please visit the SQL course page for more information, where you can find the SQL tutorials and SQL frequently asked interview questions and answers as well.


This topic has been locked/unapproved. No replies allowed

Login to participate in this discussion.

Leave a reply

Before proceeding, please check your email for a verification link. If you did not receive the email, click here to request another.