How to fix CR_VERSION_ERROR (2007): Protocol mismatch in MySQL

MySQLINTERMEDIATEHIGHUpdated Dec 22, 2025ยท 185 views

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.

Quick fix

Fixes CR_VERSION_ERROR (2007): Protocol mismatch

// 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
});
  1. Verify your connection port
  2. Check MySQL version compatibility
  3. Update client library if needed
  4. Fix Docker port mapping issues
mysql โ€” error
// 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
});
CR_VERSION_ERROR (2007): Protocol mismatch

What this error means

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).

Typical symptoms

  • Connection fails with 'Protocol mismatch; server version = 11, client version = 10'
  • Cannot connect to MySQL database from application or tools
  • Error appears after upgrading MySQL or client libraries
  • Works with one connection method but fails with another
  • Docker-based MySQL containers fail to connect from applications

Common causes

  1. Connecting to X Protocol port (33060) using classic MySQL protocol client
  2. MySQL client version is too old for the server version
  3. MySQL server version is too old for the client library
  4. Incorrect port mapping in Docker or other container environments
  5. Authentication plugin mismatch (e.g., caching_sha2_password vs mysql_native_password in MySQL 8)
  6. Middleware or database proxy misconfiguration
  7. Network configuration routing connections to wrong protocol endpoint

How to fix "CR_VERSION_ERROR (2007): Protocol mismatch"

1Verify your connection port

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:

javascript
// 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
});
2Check MySQL version compatibility

Verify your MySQL server and client library versions are compatible:

bash
# On MySQL server
mysql --version
SELECT VERSION();

# Check Node.js mysql2 version
npm list mysql2

Versions 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

3Update client library if needed

If your client library is significantly older than the server, update it:

bash
# Update mysql2 package
npm install mysql2@latest

# Update mysql package (older, less recommended)
npm install mysql@latest

For Node.js, mysql2 is preferred as it supports MySQL 5.7+ with better performance.

4Fix Docker port mapping issues

If using Docker, verify your MySQL container port mapping is correct:

bash
# 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.0

When connecting from your application:

yaml
# 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: 3306
5Configure MySQL 8 authentication if needed

MySQL 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:

bash
# Start MySQL server with legacy authentication
mysql --default-authentication-plugin=mysql_native_password

# Or in my.cnf
[mysqld]
default-authentication-plugin=mysql_native_password

Or in Docker:

bash
docker run -d -p 3306:3306 mysql:8.0 --default-authentication-plugin=mysql_native_password
6Verify the connection

Test the connection with the correct configuration:

javascript
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.

Advanced notes

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.

Frequently asked questions

What does "CR_VERSION_ERROR (2007): Protocol mismatch" mean?
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.
How do I fix "CR_VERSION_ERROR (2007): Protocol mismatch"?
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.
What causes "CR_VERSION_ERROR (2007): Protocol mismatch"?
Connecting to X Protocol port (33060) using classic MySQL protocol client MySQL client version is too old for the server version MySQL server version is too old for the client library
Is the "CR_VERSION_ERROR (2007): Protocol mismatch" error serious?
Yes. This is a high-severity error that usually blocks work until it is fixed, but the steps above resolve it.

Official resources & further reading