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

Total
0
Shares

Consider:

./mysqladmin -u root -p** '_redacted_'  

Output (including typing the password):

Enter password:

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

How can I fix this?


Solution

  1. Open and edit /etc/my.cnf or /etc/mysql/my.cnf, depending on your distribution.
  2. Add skip-grant-tables under [mysqld]
  3. Restart MySQL
  4. You should be able to log in to MySQL now using the below command mysql -u root -p
  5. Run mysql> flush privileges;
  6. Set new password by 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: StackOverflow.com

Leave a Reply

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