Cannot make remote connection with PyMySQL (pymysql.err.InternalError: Packet sequence number wrong)

放肆的年华 提交于 2019-11-28 06:45:00

问题


update: Problem solved, solution posted below

I am new to the process of making remote database connections, but it seems that there tends not to be an obvious solution for this error.

pymysql.err.InternalError: Packet sequence number wrong - got 80 expected 0 arises when attempting to make the following pymysql connection

I'm running MacOS 10.12.5, Python 2.7.10 in PyCharm (also tried with Terminal), and PyMySQL 0.7.11 (also tried 0.7.9)

update: also tried on Windows 10, Python 2.7.13 with the same result

The database is hosted on cPanel. Perhaps there are additional settings to change before I can connect. The connecting user has full privileges. My IP was added to the host "access" list.

other notes: As might be expected, if the port number or host IP is randomly changed, it immediately refuses the connection. Otherwise, it takes about 30 seconds before the 'packet sequence' error to arise.

import pymysql.cursors
import pymysql

connection = pymysql.connect(host = hostIPaddress,
                             port = 2083,
                             user = username,
                             passwd = password,
                             db = dbName,
                             charset = 'utf8mb4', # also tried 'utf8'
                             cursorclass=pymysql.cursors.DictCursor)

回答1:


While the port 2083 is used by the host, each database uses the default port 3306 in this case.

When tested with 3306, access was denied until I added the denied IP to the host "access" list in Remote MySQL on cPanel.



来源:https://stackoverflow.com/questions/46145845/cannot-make-remote-connection-with-pymysql-pymysql-err-internalerror-packet-se

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!