bhu Boue vidya
bhu Boue vidya

Reputation: 389

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

Upvotes: 5

Views: 5282

Answers (1)

Marc B
Marc B

Reputation: 360772

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

Upvotes: 3

Related Questions