Troubleshooting Access Denied Error for 'root'@'localhost'
Scenario:
When attempting to reset the password for the MySQL user 'root', you encounter the error:
Access denied for user 'root'@'localhost' (using password: NO)
Investigation:
This error indicates a permissions issue preventing you from modifying user settings. The error occurs despite you having granted all privileges to 'root'@'localhost'.
Solution:
To resolve this issue, follow these steps:
$ mysql -u root -p
mysqladmin -u root -p password foo
Explanation:
The command mysqladmin allows you to configure MySQL server settings without logging in. In this case, the -p option prompts for a password, and the password argument specifies that we are setting the user's password. The word "password" in the command should be typed literally, as it's a command and not the actual password itself.
The above is the detailed content of How to Fix \'Access denied for user \'root\'@\'localhost\' (using password: NO)\' Error When Resetting MySQL Root Password?. For more information, please follow other related articles on the PHP Chinese website!