我是python的新手,试图通过编写连接到我们的mysql数据库的服务器脚本来学习一些东西并做一些事情 . 我有python 3.3.1和mysql 5.0.96(社区) . 我安装了mysql connector / python,并尝试使用mysql开发站点上的示例代码进行基本连接 . 这是我简单的python脚本:
#!/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()
但我收到连接到数据库的错误
"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
我究竟做错了什么?任何帮助非常感谢
1 回答
MySQL支持两种密码加密方案,而您的使用旧的旧版本 . 较新的客户拒绝使用它们,因为它们非常容易破解 .
您需要将密码更新为新样式:http://dev.mysql.com/doc/refman/4.1/en/old-client.html