Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
727 views
in Technique[技术] by (71.8m points)

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

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)
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...