Wednesday, October 28, 2020

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

Issue:

mysqladmin: connect to server at 'localhost' failed error: 'Access denied for user 'root'@'localhost' (using password: YES)'

Solution: 

1.Edit /etc/my.cnf or /etc/mysql/my.cnf, depending on your distro.
2.Add skip-grant-tables under [mysqld]
3.Restart Mysql
4.You should be able to login to mysql now using the below command 

#mysql -u root -p

5.Flush privileges. 

#mysql> flush privileges;

6.Set new password by 

#mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'NewPassword';

7.Go back to /etc/my.cnf and remove/comment skip-grant-tables
8.Restart Mysql
9.Now you will be able to login with the new password #mysql -u root -p 

Source: https://stackoverflow.com/questions/41645309/mysql-error-access-denied-for-user-rootlocalhost

Related Posts:

0 comments:

Post a Comment