Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Database connection failed: error('unpack requires a buffer of 4 bytes'). #1146

Open
bkysela opened this issue Jan 17, 2024 · 5 comments
Open

Comments

@bkysela
Copy link

bkysela commented Jan 17, 2024

When connecting using mycli I see the following on the console.

$ mycli
Connecting to socket /var/run/mysqld/mysqlx.sock, owned by user mysql
unpack requires a buffer of 4 bytes
$ 

Running with DEBUG, this is in the log.

2024-01-17 12:16:16,402 (2797336/MainThread) mycli.sqlexecute DEBUG - Connection DB Params: 
        database: 'xxxxxxx'     user: 'xxxxxxxx'    host: xxxxx      port: xxxxx      socket: '/var/run/mysqld/mysqlx.sock'   charset: 'utf8' local_infile: False     ssl: None             ssh_user: None  ssh_host: None  ssh_port: 22    ssh_password: None      ssh_key_filename: None  init_command: None
2024-01-17 12:16:16,402 (2797336/MainThread) mycli.main DEBUG - Database connection failed: error('unpack requires a buffer of 4 bytes').
2024-01-17 12:16:16,402 (2797336/MainThread) mycli.main ERROR - traceback: 'Traceback (most recent call last):\n  File "/usr/lib/python3/dist-packages/mycli/main.py", line 482, in connect\n    _connect()\n  File "/usr/lib/python3/dist-packages/mycli/main.py", line 456, in _connect\n    self.sqlexecute = SQLExecute(\n  File "/usr/lib/python3/dist-packages/mycli/sqlexecute.py", line 119, in __init__\n    self.connect()\n  File "/usr/lib/python3/dist-packages/mycli/sqlexecute.py", line 177, in connect\n    conn = pymysql.connect(\n  File "/usr/lib/python3/dist-packages/pymysql/connections.py", line 353, in __init__\n    self.connect()\n  File "/usr/lib/python3/dist-packages/pymysql/connections.py", line 632, in connect\n    self._get_server_information()\n  File "/usr/lib/python3/dist-packages/pymysql/connections.py", line 1065, in _get_server_information\n    self.server_thread_id = struct.unpack("<I", data[i : i + 4])\nstruct.error: unpack requires a buffer of 4 bytes\n'
$ mycli --version
Version: 1.27.0
$ mysqld --version
/usr/sbin/mysqld  Ver 8.0.35-0ubuntu0.22.04.1 for Linux on x86_64 ((Ubuntu))

The regular MySQL client connects without issue.

@dzdidi
Copy link

dzdidi commented Jan 22, 2024

same problem on same OS verion

@asrul10
Copy link

asrul10 commented May 8, 2024

Any update?
I had same issue with ubuntu 24.04, mysql 8.0.36, and mycli 1.27.0

@8Everglow1
Copy link

same how to fix

@YoukeZhang
Copy link

You can try to add -h127.0.0.1, the same problem I had was fixed by adding this

@KamilMr
Copy link

KamilMr commented Sep 30, 2024

You can try to add -h127.0.0.1, the same problem I had was fixed by adding this

That line fixed the problem for me also. But I wonder why? Any hints to understand this?

lazmond3 added a commit to lazmond3/mycli that referenced this issue Oct 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants