bhu*_*dya 5 python mysql python-3.x
我是python的新手,试图通过编写连接到我们的mysql数据库并做一些事情的服务器脚本来学习一些知识。我有python 3.3.1和mysql 5.0.96(社区)。我安装了mysql连接器/ 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()
Run Code Online (Sandbox Code Playgroud)
但我在连接数据库时遇到错误
"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
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?任何帮助表示赞赏
MySQL 支持两种密码加密方案,您使用的是旧版本。新客户拒绝使用它们,因为它们非常容易破解。
您需要将密码更新为新样式:http://dev.mysql.com/doc/refman/4.1/en/old-client.html