0

Some time ago I had tried to install MySQL workbench correctly on my system, and it was a tremendous headache. This is because I use Kubuntu with a very new version of Ubuntu Release, and I had a lot of problems. At some point (I don't know which one exactly) I must have done something that totally complicated my MySQL. I had to reinstall it again due to these problems, I reinstalled my MySQL and I can currently log into it smoothly through the CLI.

My MySQL runs on:

tcp6 0 0 :::33060 :::* LISTEN -

This is my code, it's pretty simple:

conexao = pymysql.connect(host="localhost", user='root', password='(pass)', database='sistema', port=33060)    

But it generates this error:

Traceback (most recent call last):
  File "/home/user/Documentos/SellBot/db.py", line 3, in <module>
    conexao = pymysql.connect(host="localhost", user='root', password='(pass)', database='sistema', port=33060)
  File "/home/user/Documentos/SellBot/venv/lib/python3.13/site-packages/pymysql/connections.py", line 365, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/user/Documentos/SellBot/venv/lib/python3.13/site-packages/pymysql/connections.py", line 680, in connect
    self._get_server_information()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/user/Documentos/SellBot/venv/lib/python3.13/site-packages/pymysql/connections.py", line 1109, in _get_server_information
    self.server_thread_id = struct.unpack("<I", data[i : i + 4])
                            ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
struct.error: unpack requires a buffer of 4 bytes

What is causing this error?

My Python version: Python 3.13.3
My PyMySQL version: PyMySQL==1.1.2
OS: Kubuntu x86_64

New contributor
Pedro Wagner is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
4
  • I can currently log into it smoothly through the CLI. please edit the question to demonstrate this - use a code block to show the args you use and the resultant prompt - your cli arguments may indicate the correct python args to use. Commented 15 hours ago
  • 1
    This question is similar to: Python error: unpack requires a buffer of 4 bytes, when using PyMySQL,. If you believe it’s different, please edit the question, make it clear how it’s different and/or how the answers on that question are not helpful for your problem. Commented 15 hours ago
  • As hinted at by the linked duplicate, the most likely cause of that error is the responding host/port is not mysql. Commented 15 hours ago
  • The default port for MySQL is 3306. It’s 33060 only when using X-Protocol. Are you certain your instance is running on 33060; have you tried 3306? Commented 15 hours ago

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.