MySQL没有建立与数据库的连接

时间:2015-03-05 21:47:52

标签: python mysql

我试图连接到远程MySQL数据库,我遇到了这个错误

  "Lost connection to MySQL server during query (%s)" % (e,))
peewee.OperationalError: (2013, 'Lost connection to MySQL server during query ([Errno 10054] An existing connection was forcibly closed by the remote host)')

这是代码

from peewee import *

print "connecting"
db = MySQLDatabase("mydb", user="myuser", passwd="crypticpassword!", port=someport, host="someremotehost.com")
db.connect()
print "connected"

所以我想,确定,让我们尝试连接而不使用代码。我尝试使用Heidi,通过Microsoft SQL Server连接,没有任何问题。我应该考虑哪些想法来解决这个问题?

1 个答案:

答案 0 :(得分:-1)

确保已下载mysql How to install Python MySQLdb module using pip? 还导入mysql

import MySQLdb