I am trying to connect to mysql database via pymysql. Everything works when I SSH into the database via terminal. So, that information is correct. However, when I put the same information in using pymysql, I get the following error:
pymysql.err.InternalError: Packet sequence number wrong - got 45 expected 0
pymysql version: 0.9.2
Code (note that I changed the information regarding host, user, password, db, and port for security reasons).
import pymysql.cursors
connection = pymysql.connect(host='myhost',
user='userid',
password='mypassword',
db='my_database',
charset='utf8mb4',
port=9047,
cursorclass=pymysql.cursors.DictCursor)
except Exception as e:
print('connection failed')
print(e)
This code was working earlier. I had to upgrade packages for another project and now it quit working. I think this may be the reason.
Has anyone run into this before? If so, how did you solve it?
Thanks!
*I have also tried with different ports. I notice here that they used the port 22 or 3306, but with port 22, I get a timeout error and port 3306, I get an access denied error.