{"record":{"id":"deab31a352e8a60b","repo":"go-sql-driver/mysql","slug":"mysql-server-does-not-support-required-protocol-41","errorCode":null,"errorMessage":"MySQL server does not support required protocol 41+","messagePattern":"MySQL server does not support required protocol 41\\+","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"errors.go","lineNumber":26,"sourceCode":"\npackage mysql\n\nimport (\n\t\"errors\"\n\t\"fmt\"\n\t\"log\"\n\t\"os\"\n)\n\n// Various errors the driver might return. Can change between driver versions.\nvar (\n\tErrInvalidConn       = errors.New(\"invalid connection\")\n\tErrMalformPkt        = errors.New(\"malformed packet\")\n\tErrNoTLS             = errors.New(\"TLS requested but server does not support TLS\")\n\tErrCleartextPassword = errors.New(\"this user requires clear text authentication. If you still want to use it, please add 'allowCleartextPasswords=1' to your DSN\")\n\tErrNativePassword    = errors.New(\"this user requires mysql native password authentication\")\n\tErrOldPassword       = errors.New(\"this user requires old password authentication. If you still want to use it, please add 'allowOldPasswords=1' to your DSN. See also https://github.com/go-sql-driver/mysql/wiki/old_passwords\")\n\tErrUnknownPlugin     = errors.New(\"this authentication plugin is not supported\")\n\tErrOldProtocol       = errors.New(\"MySQL server does not support required protocol 41+\")\n\tErrPktSync           = errors.New(\"commands out of sync. You can't run this command now\")\n\tErrPktSyncMul        = errors.New(\"commands out of sync. Did you run multiple statements at once?\")\n\tErrPktTooLarge       = errors.New(\"packet for query is too large. Try adjusting the `Config.MaxAllowedPacket`\")\n\tErrBusyBuffer        = errors.New(\"busy buffer\")\n\n\t// errBadConnNoWrite is used for connection errors where nothing was sent to the database yet.\n\t// If this happens first in a function starting a database interaction, it should be replaced by driver.ErrBadConn\n\t// to trigger a resend. Use mc.markBadConn(err) to do this.\n\t// See https://github.com/go-sql-driver/mysql/pull/302\n\terrBadConnNoWrite = errors.New(\"bad connection\")\n)\n\nvar defaultLogger = Logger(log.New(os.Stderr, \"[mysql] \", log.Ldate|log.Ltime))\n\n// Logger is used to log critical error messages.\ntype Logger interface {\n\tPrint(v ...any)","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/go-sql-driver/mysql/blob/03d76c7e07908e255ce62d126d07ede3f2365d86/errors.go#L8-L44","documentation":"ErrOldProtocol is returned from readHandshakePacket (packets.go:217) when the server's capability flags lack clientProtocol41. The driver mandates the 4.1+ protocol (protocol version 10, const.go:18) and will not negotiate the legacy wire format.","triggerScenarios":"Connecting to a MySQL server older than 4.1 whose handshake does not advertise the protocol-41 capability bit; effectively unreachable with any modern client.","commonSituations":"Embedded systems or ancient appliances bundling MySQL 3.x/4.0; misdirected DSN pointing at a non-MySQL service that returns a pre-41-style handshake.","solutions":["Upgrade the server to MySQL/MariaDB 4.1 or newer (anything from the last ~20 years).","Verify the address actually points at a MySQL server and not another protocol on that port.","If a legacy server is unavoidable, use an older client stack that still speaks the pre-41 protocol."],"exampleFix":"// before\n//   mysqld 4.0.x -> ErrOldProtocol on every connect\n\n// after: run a supported server version (5.7 / 8.0 / MariaDB 10.x+)\n//   the handshake advertises clientProtocol41 and the error disappears","handlingStrategy":"validation","validationCode":"// Sanity-check the server version during provisioning so a pre-4.1 server\n// is caught before the app tries to connect.\n//   SELECT VERSION();  -- must be >= 4.1 / protocol 10","typeGuard":"func isOldProtocol(err error) bool {\n    return errors.Is(err, mysql.ErrOldProtocol)\n}","tryCatchPattern":"if errors.Is(err, mysql.ErrOldProtocol) {\n    // not fixable client-side: upgrade the server or retarget the DSN.\n}","preventionTips":["Run a supported MySQL/MariaDB version (>= 4.1).","Verify the DSN host:port is a real MySQL server.","Treat ErrOldProtocol as a deployment misconfiguration, not a runtime blip."],"tags":["protocol","handshake","legacy","compatibility"],"backgroundTag":null,"analyzedSha":"03d76c7e07908e255ce62d126d07ede3f2365d86","analyzedAt":"2026-08-07T10:39:17.340Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}