首页 文章

使用python 3.3.1连接到mysql数据库的密码错误

提问于
浏览
4

我是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 回答

相关问题