我正在尝试连接到远程 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 How to install Python MySQLdb module using pip? 同时导入mysql
import MySQLdb
关于python - MySQL 没有建立与数据库的连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28888401/