A protocol mismatch occurs when your MySQL client cannot communicate with the server due to incompatible protocol versions. This typically happens after version upgrades, downgrades, or when connecting to the wrong port.
The MySQL client cannot communicate with the server because they are expecting different protocol versions. This typically happens when: 1. You're connecting to the wrong port (33060 for X Protocol instead of 3306 for classic MySQL protocol) 2. Your MySQL client and server versions are significantly mismatched 3. Authentication protocol differences (e.g., MySQL 8's caching_sha2_password vs older mysql_native_password) 4. Middleware or proxies are intercepting connections and causing protocol translation issues The error message shows both the server protocol version (usually 11 for MySQL 8) and the client protocol version (usually 10 for older clients).
Check that you're connecting to the correct MySQL port. Use:
- Port 3306 for classic MySQL protocol (most common)
- Port 33060 for X Protocol (MySQL 8.0+, rarely used by traditional clients)
Verify in your connection string:
// CORRECT: Using port 3306 (classic protocol)
const connection = mysql.createConnection({
host: 'localhost',
user: 'root',
password: 'password',
database: 'mydb',
port: 3306
});
// WRONG: Using port 33060 with classic MySQL client
const connection = mysql.createConnection({
host: 'localhost',
user: 'root',
password: 'password',
database: 'mydb',
port: 33060 // This is X Protocol port, incompatible with mysql/mysql2
});Verify your MySQL server and client library versions are compatible:
# On MySQL server
mysql --version
SELECT VERSION();
# Check Node.js mysql2 version
npm list mysql2Versions should be reasonably close. If you have:
- MySQL 5.7 client connecting to MySQL 8.0+ server, upgrade the client library
- Very old MySQL server (5.0-5.5) with modern client, check for deprecated authentication methods
If your client library is significantly older than the server, update it:
# Update mysql2 package
npm install mysql2@latest
# Update mysql package (older, less recommended)
npm install mysql@latestFor Node.js, mysql2 is preferred as it supports MySQL 5.7+ with better performance.
If using Docker, verify your MySQL container port mapping is correct:
# CORRECT: Maps container port 3306 to host port 3306
docker run -d -p 3306:3306 mysql:8.0
# WRONG: Maps container port 33060 to host port 3306
docker run -d -p 3306:33060 mysql:8.0When connecting from your application:
# docker-compose.yml - CORRECT
services:
db:
image: mysql:8.0
ports:
- "3306:3306" # host:container
environment:
MYSQL_ROOT_PASSWORD: password
# Application connection
host: db
port: 3306MySQL 8.0+ uses caching_sha2_password by default, which may not be supported by older client libraries. If updating isn't an option, configure MySQL to use the legacy authentication:
# Start MySQL server with legacy authentication
mysql --default-authentication-plugin=mysql_native_password
# Or in my.cnf
[mysqld]
default-authentication-plugin=mysql_native_passwordOr in Docker:
docker run -d -p 3306:3306 mysql:8.0 --default-authentication-plugin=mysql_native_passwordTest the connection with the correct configuration:
const mysql = require('mysql2/promise');
const connection = await mysql.createConnection({
host: 'localhost',
user: 'root',
password: 'password',
database: 'mydb',
port: 3306 // Classic MySQL port
});
console.log('Connected successfully!');
await connection.end();If successful, the protocol mismatch is resolved.
Protocol Difference: MySQL has two protocols:
- Classic MySQL Protocol (port 3306): Traditional protocol used since MySQL 3.21, supported by all clients
- X Protocol (port 33060): Introduced in MySQL 5.7.12, used by MySQL Shell and modern APIs
They are NOT interchangeable. Your client must match the protocol of the port you're connecting to.
Version Reporting: The error message shows server version = 11, client version = 10. These are NOT MySQL version numbers (like 5.7 or 8.0). They refer to the protocol version numbers. This often confuses developers.
MySQL 8 Authentication Plugins: MySQL 8 changed the default authentication from mysql_native_password to caching_sha2_password. Older clients (especially those supporting only mysql_native_password) will fail. The error may appear as a protocol mismatch when it's actually an authentication incompatibility.
Production Consideration: Always keep client and server versions within 1-2 major versions of each other. If connecting across significant version gaps, explicitly test the connection type before deploying to production.
EE_WRITE (3): Error writing file
How to fix "EE_WRITE (3): Error writing file" in MySQL
CR_PARAMS_NOT_BOUND (2031): No data supplied for parameters
How to fix "CR_PARAMS_NOT_BOUND (2031): No data supplied for parameters" in MySQL
CR_DNS_SRV_LOOKUP_FAILED (2070): DNS SRV lookup failed
How to fix "CR_DNS_SRV_LOOKUP_FAILED (2070): DNS SRV lookup failed" in MySQL
ERROR 1146: Table 'database.table' doesn't exist
How to fix "ERROR 1146: Table doesn't exist" in MySQL
ERROR 1040: Too many connections
How to fix "ERROR 1040: Too many connections" in MySQL