Error Encountered:
Upon attempting to access MySQL using the command line, a user receives the following error:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
Cause:
This error indicates that the MySQL server is denying access to the specified user (usually "root") with the given password.
Solution:
Since password resetting has proven ineffective, a more thorough approach is required.
Reinstalling MySQL with Complete Removal
Additional Tips
Reset Root Password:
While MySQL is running with --skip-grant-tables, connect to the MySQL client and reset the root password. For MySQL 5.7 or later, use the following command:
UPDATE mysql.user SET authentication_string=PASSWORD('new_password') WHERE User='root';
Flush Privileges:
After resetting the password, flush the privileges to ensure the changes take effect:
FLUSH PRIVILEGES;
By following these steps, you can resolve the "Access denied" error and regain access to your MySQL server with a default installation.
The above is the detailed content of MySQL ERROR 1045: How to Fix 'Access Denied' Even After Password Reset?. For more information, please follow other related articles on the PHP Chinese website!