Access Denied For User Root@Localhost

Originally written: December 7th, 2020

First, acknowledgement: this article is thanks to phoenixnap.

When you first install mysql, you may get an error like the following:

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

This error held up me up for a while; I think I spent an hour frustratingly trying to resolve this configuration error.

Turns out the solution is actually simple. First, boot up mysql by running sudo mysql in your favorite shell. Then, run:

              
               ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'your_password';
              
            
Where "your_password" is something you designate; i.e. if you want to set your password as "1234", then you would write

              
               ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '1234';
              
            
Hope this helps!