简体   繁体   English

MySQL未建立与数据库的连接

[英]MySQL not establishing connection to database

I'm trying to connect to a remote MySQL database and I'm running into this error 我正在尝试连接到远程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)')

Here's the code 这是代码

from peewee import *

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

so I figured, sure, let's try connecting without using code. 所以我想当然了,让我们尝试不使用代码进行连接。 I tried using Heidi, connecting through Microsoft SQL Server, and no problems whatsoever. 我尝试使用Heidi,通过Microsoft SQL Server连接,没有任何问题。 Any ideas where I should look into to fix this? 我有什么想法可以解决此问题?

Make sure you have mysql downloaded How to install Python MySQLdb module using pip? 确保您已下载mysql。 如何使用pip安装Python MySQLdb模块? Also import mysql 还导入mysql

import MySQLdb

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

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