繁体   English   中英

MySQL未建立与数据库的连接

[英]MySQL not establishing connection to database

我正在尝试连接到远程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连接,没有任何问题。 我有什么想法可以解决此问题?

确保您已下载mysql。 如何使用pip安装Python MySQLdb模块? 还导入mysql

import MySQLdb

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM