6 May 2020

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

  • Connect to mysql using below commands
    • sudo su
    • mysql
  • Check if the user root is using mysql_native_password OR auth_socket
    • SELECT user, host, authentication_string, plugin FROM mysql.user;
  • It may have a blank value in authentication_string column and auth_socket in plugin column
  • If that is the case, update user root with the following queries.
    • ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'New-Root-Password';
    • FLUSH PRIVILEGES;
That is all you need to do.

No comments:

Post a Comment