{"record":{"id":"fcecf88b3e627bc6","repo":"sqlmapproject/sqlmap","slug":"handshake-failed-s","errorCode":null,"errorMessage":"handshake failed (%s)","messagePattern":"handshake failed \\((.+?)\\)","errorType":"exception","errorClass":"OperationalError","httpStatus":null,"severity":"error","filePath":"extra/dbwire/mysql.py","lineNumber":350,"sourceCode":"        if not (flags & _CLIENT_PLUGIN_AUTH):\n            plugin = None       # pre-4.1.1 style: no trailing plugin name in the handshake response\n        response = struct.pack(\"<I\", flags) + struct.pack(\"<I\", _MAX_PACKET) + struct.pack(\"<B\", 45) + (b\"\\x00\" * 23)\n        response += (user or \"\").encode(\"utf-8\") + b\"\\x00\"\n        response += struct.pack(\"<B\", len(auth_response)) + auth_response\n        if database:\n            response += database.encode(\"utf-8\") + b\"\\x00\"\n        if plugin:\n            response += plugin.encode(\"ascii\") + b\"\\x00\"\n        _send_packet(sock, seq + 1, response)\n\n        _finish_auth(sock, password or \"\", plugin or \"mysql_native_password\", salt)\n        handshake_done(sock)\n    except (DatabaseError, InterfaceError):\n        _safe_close(sock)\n        raise\n    except Exception as ex:\n        _safe_close(sock)\n        raise OperationalError(\"handshake failed (%s)\" % ex)\n\n    connection = Connection(sock)\n    # SET NAMES: reset collation_connection to the server's default (the fixed handshake collation 45 =\n    # utf8mb4_general_ci otherwise clashes with MySQL 8's utf8mb4_0900_ai_ci columns -> 'illegal mix of\n    # collations' 1271 in a UNION/CONCAT); results stay utf8mb4 so the utf-8 decode is unchanged. autocommit=1\n    # so DML persists even if the server default is autocommit=0. Best-effort (one-time, at connect) - but the\n    # charset has to land on *something*, else rows decode as utf-8 that never was: pre-5.5.3 servers have no\n    # utf8mb4, and 'utf8' (3-byte) is the fallback every 4.1+ server does have.\n    for alternatives in ((\"SET NAMES utf8mb4\", \"SET NAMES utf8\"), (\"SET autocommit=1\",)):\n        for setup in alternatives:\n            try:\n                connection._query(setup)\n                break\n            except Exception:\n                pass\n    return connection\n\ndef _safe_close(sock):","sourceCodeStart":332,"sourceCodeEnd":368,"githubUrl":"https://github.com/sqlmapproject/sqlmap/blob/0a35b20e3953d341be6c7ac75ccb0b3362540c8d/extra/dbwire/mysql.py#L332-L368","documentation":"Error \"handshake failed (%s)\" thrown in sqlmapproject/sqlmap.","triggerScenarios":"Thrown at extra/dbwire/mysql.py:350 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0a35b20e3953d341be6c7ac75ccb0b3362540c8d","analyzedAt":"2026-08-26T23:02:52.002Z","schemaVersion":2},"datasetVersion":"2026-08-27T03:17:27.898Z"}