{"record":{"id":"8af64579bab14a5d","repo":"go-sql-driver/mysql","slug":"unsupported-protocol-version-d-version-d-or-hig","errorCode":null,"errorMessage":"unsupported protocol version %d. Version %d or higher is required","messagePattern":"unsupported protocol version (.+?)\\. Version (.+?) or higher is required","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"packets.go","lineNumber":197,"sourceCode":"******************************************************************************/\n\n// Handshake Initialization Packet\n// https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_connection_phase_packets_protocol_handshake_v10.html\n// https://mariadb.com/kb/en/connection/#initial-handshake-packet\nfunc (mc *mysqlConn) readHandshakePacket() (data []byte, capabilities capabilityFlag, extendedCapabilities extendedCapabilityFlag, plugin string, err error) {\n\tdata, err = mc.readPacket()\n\tif err != nil {\n\t\treturn\n\t}\n\n\tif data[0] == iERR {\n\t\terr = mc.handleErrorPacket(data)\n\t\treturn\n\t}\n\n\t// protocol version [1 byte]\n\tif data[0] < minProtocolVersion {\n\t\treturn nil, 0, 0, \"\", fmt.Errorf(\n\t\t\t\"unsupported protocol version %d. Version %d or higher is required\",\n\t\t\tdata[0],\n\t\t\tminProtocolVersion,\n\t\t)\n\t}\n\n\t// server version [null terminated string]\n\t// connection id [4 bytes]\n\tpos := 1 + bytes.IndexByte(data[1:], 0x00) + 1 + 4\n\n\t// first part of the password cipher [8 bytes]\n\tauthData := data[pos : pos+8]\n\n\t// (filler) always 0x00 [1 byte]\n\tpos += 8 + 1\n\n\t// capability flags (lower 2 bytes) [2 bytes]\n\tcapabilities = capabilityFlag(binary.LittleEndian.Uint16(data[pos : pos+2]))","sourceCodeStart":179,"sourceCodeEnd":215,"githubUrl":"https://github.com/go-sql-driver/mysql/blob/03d76c7e07908e255ce62d126d07ede3f2365d86/packets.go#L179-L215","documentation":"The server's initial handshake packet begins with a 1-byte protocol version; the driver requires >= 10 (minProtocolVersion). A lower version means an ancient or incompatible server that this driver cannot talk to.","triggerScenarios":"Connecting to a pre-protocol-10 server (pre-MySQL 3.x) or to a non-MySQL service that happens to listen on port 3306 and emits a different protocol version byte.","commonSituations":"Pointing the driver at the wrong host/port (another service); a very old embedded MySQL fork; misconfigured port forwarding.","solutions":["Connect to a modern MySQL or MariaDB server, which all speak protocol version 10.","Verify the host/port actually point at a MySQL/MariaDB server (e.g. with a mysql CLI or telnet).","Upgrade or replace the incompatible server."],"exampleFix":"null","handlingStrategy":"validation","validationCode":"// Before relying on the connection, ping to confirm a compatible server.\nif err := db.Ping(); err != nil {\n    return fmt.Errorf(\"cannot reach compatible MySQL server: %w\", err)\n}","typeGuard":"null","tryCatchPattern":"// The error surfaces at connect/Ping time.\ndb, err := sql.Open(\"mysql\", dsn)\nif err == nil {\n    err = db.Ping()\n}\nif err != nil {\n    return err\n}","preventionTips":["Confirm the target is a real MySQL/MariaDB server with the mysql CLI.","Keep the server on a supported (protocol 10) version.","Validate connectivity with db.Ping at startup."],"tags":["go","mysql","protocol","connection","server-compat"],"backgroundTag":null,"analyzedSha":"03d76c7e07908e255ce62d126d07ede3f2365d86","analyzedAt":"2026-08-07T10:39:17.340Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}