Jump to content

MYSQL.CONNECTOR ISSUE


D.B.
 Share

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

con=mysql.connector.connect(host='localhost',user='root',passwd='12345',database='empl')

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.

pythonneed.png

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

Posted (edited)

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")

Otherwise,

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
 Share

×
×
  • Create New...