I am trying to connect MySQL(8.0.25) and python(3.9.6) using mysql.connector but getting error.
mysql.connector.errors.ProgrammingError: 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
import mysql.connector as sql
s =sql.connect(host='localhost',user='root', password='<correct password>',database='<existing database>')
The password I entered is the one I use to successfully login to MySQL 8.0 Command line client.
Same code is working for pymysql.connect without any error.
I checked out the Host and User Name by logging in to MYSQL 8.0 Command Line client with my password and typing:
Perhaps a few side notes about VsCode. VsCode is a code editor that supports a plethora of Plugins. It is one of the most popular code editors and supports many programming languages. It is also completely free and supported under Windows, Linux and MacOs.
It might be a good idea to use VsCode if you want to make programming your profession at some point. I worked with different programming languages using VsCode in different companies. It hasn’t failed me yet.