Explore Courses Blog Tutorials Interview Questions
0 votes
in SQL by (20.3k points)

$ ./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?

1 Answer

0 votes
by (40.7k points)

To fix MySQL Error: : 'Access denied for user 'root'@'localhost', you should follow these steps:

Step 1: Open and Edit /etc/my.cnf or /etc/mysql/my.cnf, according to your distro.

Step 2: Add skip-grant-tables which is under [mysqld]

Step 3: Now, Restart Mysql

You must be able to login to mysql now by using the below command mysql -u root -p

Run mysql> flush privileges;

Now, set new password by ALTER USER 'root'@'localhost' IDENTIFIED BY 'NewPassword'; and go back to /etc/my.cnf and remove/comment skip-grant-tables

Again, Restart Mysql, now you can login with the new password 

mysql -u root -p

You can master these queries and become proficient in SQL queries by enrolling in an industry-recognized SQL certification.

Browse Categories