简体   繁体   中英

MySQL not establishing connection to database

I'm trying to connect to a remote MySQL database and I'm running into this error

  "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. Any ideas where I should look into to fix this?

Make sure you have mysql downloaded How to install Python MySQLdb module using pip? Also import mysql

import MySQLdb

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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