sqlmapproject/sqlmap · error · OperationalError
handshake failed (%s)
Error message
handshake failed (%s)
What it means
Error "handshake failed (%s)" thrown in sqlmapproject/sqlmap.
Source
Thrown at extra/dbwire/mysql.py:350
if not (flags & _CLIENT_PLUGIN_AUTH):
plugin = None # pre-4.1.1 style: no trailing plugin name in the handshake response
response = struct.pack("<I", flags) + struct.pack("<I", _MAX_PACKET) + struct.pack("<B", 45) + (b"\x00" * 23)
response += (user or "").encode("utf-8") + b"\x00"
response += struct.pack("<B", len(auth_response)) + auth_response
if database:
response += database.encode("utf-8") + b"\x00"
if plugin:
response += plugin.encode("ascii") + b"\x00"
_send_packet(sock, seq + 1, response)
_finish_auth(sock, password or "", plugin or "mysql_native_password", salt)
handshake_done(sock)
except (DatabaseError, InterfaceError):
_safe_close(sock)
raise
except Exception as ex:
_safe_close(sock)
raise OperationalError("handshake failed (%s)" % ex)
connection = Connection(sock)
# SET NAMES: reset collation_connection to the server's default (the fixed handshake collation 45 =
# utf8mb4_general_ci otherwise clashes with MySQL 8's utf8mb4_0900_ai_ci columns -> 'illegal mix of
# collations' 1271 in a UNION/CONCAT); results stay utf8mb4 so the utf-8 decode is unchanged. autocommit=1
# so DML persists even if the server default is autocommit=0. Best-effort (one-time, at connect) - but the
# charset has to land on *something*, else rows decode as utf-8 that never was: pre-5.5.3 servers have no
# utf8mb4, and 'utf8' (3-byte) is the fallback every 4.1+ server does have.
for alternatives in (("SET NAMES utf8mb4", "SET NAMES utf8"), ("SET autocommit=1",)):
for setup in alternatives:
try:
connection._query(setup)
break
except Exception:
pass
return connection
def _safe_close(sock):View on GitHub (pinned to 0a35b20e39)
When it happens
Trigger: Thrown at extra/dbwire/mysql.py:350 when the library encounters an invalid state.
Common situations: See trigger scenarios.
Understand the failure class
- SSL/TLS and certificate errors — how TLS handshakes and certificate validation fail.
AI-assisted analysis of sqlmapproject/sqlmap@0a35b20e39 (2026-08-26).
Data as JSON: /api/errors/fcecf88b3e627bc6.
Report an issue: GitHub.