Jump to content



Recommended Posts

I am trying to connect mysql(8.0) and python(3.8) using mysql.connector but getting the error:

mysql.connector.errors.ProgrammingError: 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

Windows 10

The code is:

import mysql.connector


same code properly working with pymysql.connect and sqlalchemy's create_engine.

kindly see the image attached

kindly reply soon as i need to complete it for a project urgently.


Link to comment
Share on other sites

Did you put a password for root account? Otherwise don't use any password for access.

Link to comment
Share on other sites

Yes, I log in to MYSQL COMMAND LINE CLIENT using that password. After that ,I typed  'select current_user;' and got the output:

| current_user   |
| root@localhost |

which means the password I use to login is of root account and host is localhost.

Edited by D.B.
Link to comment
Share on other sites

Try to connect again adding "port" argument like this,

conn2 = mysql.connector.connect(host="localhost", user="root", passwd="12345", database="empl", port="#PORT")


Go to localhost sever using browser and make sure about that password is correct. Or make a new account (with password or without) and try to execute your queries via command line with database.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...