Why python doesn't connect to mysql.connector | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why python doesn't connect to mysql.connector

My OS is ubuntu 20.04 and to connect python to mysql I use this code : import mysql.connector cnx = mysql.connector.connect(user = 'root', password = 'My password', host = '127.0.0.1', database = 'mydb') cnx.close() But this error happens : Authentication plugin 'caching_sha2_password' is not supported Then I change my code to : import mysql.connector cnx = mysql.connector.connect(user = 'root', password = 'My password', host = '127.0.0.1', database = 'mydb', auth_plugin='mysql_native_password') cnx.close() and this error happens : Access denied for user 'root'@'localhost' Please tell me what should I do?

23rd Sep 2021, 3:16 PM
Javad Besharati
Javad Besharati - avatar
0 Answers