pymysql.err.OperationalError: (1045, "Access denied for user 'root'@'localhost' (using password: YES)")
时间: 2023-10-03 21:02:56 浏览: 163
mysql Access denied for user ‘root’@’localhost’ (using password: YES)解决方法
This error message indicates that the user 'root' does not have the correct credentials to access the MySQL database. The most common cause of this error is that the password for 'root' is incorrect.
You can try the following steps to resolve this issue:
1. Double-check that the password for 'root' is correct. Make sure that there are no typos or mistakes.
2. Verify that 'root' has the correct permissions to access the MySQL database. You can do this by logging into the MySQL server and checking the privileges for the 'root' user.
3. If you still cannot access the database, you may need to reset the password for 'root'. You can do this by logging into the MySQL server as the root user and using the following command:
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';
Replace 'new_password' with the password that you want to use for the 'root' user.
4. If none of these steps work, it may be necessary to create a new user with the correct permissions to access the MySQL database. You can do this by logging into the MySQL server and using the following command:
CREATE USER 'new_user'@'localhost' IDENTIFIED BY 'password';
Replace 'new_user' and 'password' with the username and password that you want to use for the new user.
Once you have resolved the issue, you should be able to connect to the MySQL database using the correct credentials.
阅读全文