Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

password error connecting to mysql database with python 3.3.1

i'm a newbie to python, trying to learn some stuff by writing server scripts which connect to our mysql databases and do some stuff. i have python 3.3.1, and mysql 5.0.96 (community). i installed the mysql connector/python, and tried to do a basic connection using the sample code on the mysql dev site. here is my simple python script:

#!/usr/local/bin/python3


import sys
import mysql.connector

db_config = {
    'user': 'joebloggs',
    'password': 'cleartext_passwd',
    'host': '127.0.0.1',
    'database': 'mydb'
}
cnx = mysql.connector.connect(**db_config)
cursor = cnx.cursor()
query = ('select usable_name, user_id from user')
cursor.execute(query)
for (usable_name, user_id) in cursor:
    print("{} is the usable name of {d}".format(usable_name, user_id))
cursor.close()
cnx.close()

but i am getting an error connecting to the database

"Authentication with old (insecure) passwords "\
mysql.connector.errors.NotSupportedError: Authentication with old (insecure) passwords is not supported. For more information, lookup Password Hashing in the latest MySQL manual

what am i doing wrong? any help greatly appreciated

like image 569
bhu Boue vidya Avatar asked Oct 21 '22 12:10

bhu Boue vidya


1 Answers

MySQL supports two password encryption schemes, and yours are using the old legacy version. Newer clients refuse to use those as they're pretty trivial to crack.

You need to update your passwords to the new style: http://dev.mysql.com/doc/refman/4.1/en/old-client.html

like image 158
Marc B Avatar answered Oct 27 '22 21:10

Marc B