【发布时间】:2014-11-04 05:13:02
【问题描述】:
我刚刚在 Windows 7 机器上为 Python 2.7 安装了 MySQL Python 连接器 2.0.2。我试图运行一个示例代码来创建与我的数据库的连接,但它抛出了一条错误消息。 “解析握手失败;缓冲区中不存在结束字节”。我运行以下代码:
import mysql.connector
from mysql.connector import errorcode
try:
cnx = mysql.connector.connect(user='scott',
database='testt')
except mysql.connector.Error as err:
if err.errno == errorcode.ER_ACCESS_DENIED_ERROR:
print("Something is wrong with your user name or password")
elif err.errno == errorcode.ER_BAD_DB_ERROR:
print("Database does not exists")
else:
print(err)
else:
cnx.close()
我正在使用 Python 2.7.3 和 MySQL 服务器版本 5.5.8 。如果我遗漏了什么,请告诉我。
【问题讨论】:
-
你的 MySQL 服务器在运行吗?
-
是的,它正在运行。我也用相同的用户名检查了它。
标签: python mysql mysql-python