Click here to Skip to main content
15,071,480 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I AM TRYING TO CONNECT MYSQL AND PYTHON USING MYSQL.CONNECTOR BUT GETTING THE ERROR: mysql.connector.errors.ProgrammingError: 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

What I have tried:

no help available as per my need
Updated 23-Jun-21 6:34am
Member 15254259 19-Jun-21 23:44pm
kindly reply soon as i need to resolve it at the earliest for a project
Richard MacCutchan 20-Jun-21 3:33am
Look at the error message. The user information that you are using is not valid.
Member 15254259 21-Jun-21 13:44pm
it is valid as the same user information for pymysql.connect and sqlalchemy's create_engine is working properly without any error.

1 solution

Member 15254259 23-Jun-21 12:59pm
As I mentioned, it is working properly with pymysql and sqlalchemy's create_engine, so ,there isn't any chance of the authentication data provided to be wrong. Furthermore, I have no idea regarding which version would be compatible for me and how to specifically download that version. Moreover, all privileges are granted as I have checked it.
Maciej Los 23-Jun-21 14:25pm
Take a look here: MySQL :: MySQL Connector/Python Developer Guide :: 3 Connector/Python Versions[^], where you'll find an information what version of Python and Connector is suitable.
Member 15254259 24-Jun-21 6:12am
my version is compatible according to that page. What should i do now?
Maciej Los 24-Jun-21 6:20am
I'd check MySql configuration. Maybe MySql server does NOT accept incomming connections.
Member 15254259 25-Jun-21 3:00am
But,i am able to connect using pymysql with the same statement.
Maciej Los 25-Jun-21 3:14am
Please, share the code that causes above error message. Do NOT use original user name and password! Specify what line is causing error.
Member 15254259 25-Jun-21 3:44am
import mysql.connector as s
Member 15254259 25-Jun-21 5:46am
i am working without ssh tunnel as we can't use it for our school project.
Maciej Los 25-Jun-21 5:53am
You need to change default root account, because when you install MySqlConnector it set up root account without password. There's few other things to do. Please, follow the links.
Member 15254259 25-Jun-21 5:58am
I have already set up root password which I use to login to mysql command line client, everytime i use it. I didn't find solutions to my situation in several sites and links as the cases in the links are different from mine.
Member 15254259 29-Jun-21 14:25pm
can anyone help me out kindly?

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