简体   繁体   中英

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM