Click here to Skip to main content
15,666,844 members
Please Sign up or sign in to vote.
1.44/5 (2 votes)
I AM TRYING TO CONNECT MYSQL(8.0) AND PYTHON(3.8) USING MYSQL.CONNECTOR 8.0.25 BUT GETTING THE ERROR: mysql.connector.errors.ProgrammingError: 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
code used:
import mysql.connector 

Database exists and password used is the one which is used to login to mysql command line client.Same code working with pymysql and sqlalchemy's create engine without any error.
Kindly help me out solve it for my project work.

What I have tried:

No help available as per my situation.
Updated 2-Jul-21 18:36pm
Maciej Los 5-Jul-21 4:16am    
Do NOT repost!
Mysql connector issue[^]

1 solution

Read the error message:
Error: 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

The username or password is incorrect, or you are accessing the wrong DB.

We can't fix that!

Try logging in via whatever management app you used to create the DB, then compare that login data with the actual string you use to try and log in.
Share this answer
Member 15254259 3-Jul-21 1:21am    
I have ensured that the password is correct and database also exists.
OriginalGriff 3-Jul-21 1:34am    
MySql disagrees with you! :laugh:

Seriously, log in via your management software and compare exactly what strings are used using the debugger - we can do nothing for you because we have no access to your system.
Member 15254259 4-Jul-21 0:30am    
Can you say me the steps to do that? Alongwith the code and statements to be used.
OriginalGriff 4-Jul-21 4:03am    
No, because we have no access to your system!

Code won;t help, because you need to find out why your current connection string doesn't work, and we can't help you with that.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900