Skip to content
AdminKit

MySQL wire protocol

What is MySQL wire protocol?

The MySQL wire protocol is the TCP message format MySQL's own client libraries use to connect, authenticate and exchange queries with a mysqld server, normally on port 3306. AdminKit's guide to checking an exposed MySQL port explains why a reachable 3306 has been a documented ransomware target since 2017.

By AdminKit team, Netbase JSC · Updated

The MySQL wire protocol, documented in MySQL’s own developer reference, is the message format a client or driver uses to open a connection, authenticate, and run queries over TCP, normally on port 3306, which IANA registers for MySQL. It runs in two phases: a connection phase that negotiates capabilities, authentication method and optional TLS, then a command phase that carries queries and results. It’s MySQL-specific rather than a shared database standard, which is why a PostgreSQL or MongoDB driver can’t speak to a MySQL server directly — the same relationship this glossary’s PostgreSQL wire protocol entry describes for its own database. The one close relative is MySQL’s own fork: MariaDB documents its client/server protocol, derived from MySQL’s, including the extensions where the two now differ. Whether this protocol is reachable from the internet at all depends entirely on which interface mysqld binds to, a setting separate from the authentication the protocol itself carries.

MySQL wire protocol is part of AdminKit’s machine protocols cluster; the full AdminKit glossary lists other related terms.

Frequently asked questions

Can a PostgreSQL driver connect to a MySQL server directly?

No -- the MySQL wire protocol is MySQL-specific rather than a shared database standard, so a PostgreSQL or MongoDB driver can't speak to a MySQL server without a protocol-specific client.

What two phases does the MySQL wire protocol run through?

A connection phase that negotiates capabilities, authentication method and optional TLS, then a command phase that carries queries and results.

What port does MySQL normally use?

Port 3306, which IANA's service name and port number registry assigns to MySQL.

Does the MySQL wire protocol itself control whether the server is reachable from the internet?

No -- that depends entirely on which network interface mysqld binds to, a separate setting from the authentication the protocol carries.