MySQL packets

All communication between MySQL clients and servers is done through discrete packets. Some packet types can be sent by the client to the server, others by the server to the client, and a few can be sent from either side.

Each packet type can be identified by calling getPacketType() (in Java) or retrieving the packetType property (in JavaScript), which will return the name of the packet type as described here, e.g. one of "LoginRequest", "AuthSwitchResponse", etc...

For full details, consult the MySQL documentation.

Request packets

These packet types can only be sent from the client to the server.

LoginRequest: starts the authentication process

AuthSwitchResponse: responds to an AuthSwitchRequest

HandshakeResponse41: the first packet sent by the client

Command packet: asks the server to do something

Query packet: asks the server to execute a SQL command

StatementClose packet: closes a prepared statement

StatementReset packet: reset a prepared statement

StmtExecute: requests the execution of a prepared statement

StatementPrepare: prepare a prepared statement


Response packets

These packet types can only be sent from the server to the client.

AuthMoreData: opaque packet used in authentication

AuthSwitchRequest: requests the use of a new authentication method

ColumnCount: indicates how many columns are in a result set

ColumnDefinition: describes a column

EOF: indicates the end of a stream of data

ERR: indicates an error

FieldListResponse: lists columns in response to a FieldList request

HandshakeV10: sent by the server on initial connection

OK: sent to indicate the successful completion of an exchange

ResultsetRow: contains a row in a result set

StmtExecuteResponse: response to the execution of a prepared statement

StmtPrepareOK: response to a prepare statement

Duplex packets

These packet types can be sent either from the client or from the server.

Authentication: authentication data exchanged during authentication

AuthMoreData: additional authentication data exchanged during authentication

Others

RowBatch: contains one or more ResultsetRow objects.