Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Understand the text protocol in the Server's client/server communication. This section details how SQL commands and results are exchanged as plain text, including command types and packet structures.
This command allows a connected client to re-authenticate as a different user without closing and reopening the connection.
COM_CHANGE_USER resets the connection and re-authenticates with the given credentials. The packet is identical to the authentication packet in the connection handshake.
int<1> 0x11 : COM_CHANGE_USER header.
username.
If (server_capabilities & CLIENT_SECURE_CONNECTION):
length of authentication response.
string authentication response.
Else:
authentication response.
default schema name.
client character collation.
If (server_capabilities & CLIENT_PLUGIN_AUTH):
authentication plugin name.
If (server_capabilities & CLIENT_CONNECT_ATTRS):
size of connection attributes.
Loop:
Server response is like :
An OK packet in case of success .
An error packet in case of error .
Authentication switch:
If the client or server doesn't have PLUGIN_AUTH
If the authentication fails more than three times, all future COM_CHANGE_USER commands on the connection will return the #08S01 Unknown command error. This is an anti-brute-force mechanism designed to prevent rapid guessing of passwords.
This page is licensed: CC BY-SA / Gnu FDL
This command retrieves a list of active threads and their current status, similar to the SHOW PROCESSLIST statement.
This page is licensed: CC BY-SA / Gnu FDL
string value.
Server sends 0xFE byte.
Client sends old_password.
Else:
Server sends Authentication switch request.
Client may have many exchanges with the server according to the Plugin.
Authentication switch ends with server sending either OK_Packet or ERR_Packet.
int<1> 0x00: COM_SLEEP header.
This page is licensed: CC BY-SA / Gnu FDL
string schema name.
ERR_Packet or OK_Packet.
This page is licensed: CC BY-SA / Gnu FDL
06 00 00 00 02 74 65 73 74 63 .....testcThis page is licensed: CC BY-SA / Gnu FDL
This page is licensed: CC BY-SA / Gnu FDL
This command drops an existing database from the server, functionally equivalent to the SQL statement DROP DATABASE.
This page is licensed: CC BY-SA / Gnu FDL
This command retrieves a human-readable string containing internal server statistics like uptime and thread counts.
Get internal server statistics.
int<1> 0x09 : COM_STATISTICS header.
human-readable string.
This page is licensed: CC BY-SA / Gnu FDL
This command requests the server to shut down, it requires the SHUTDOWN privilege to be executed successfully.
This command instructs the server to close the connection and release associated resources.
Using the COM_QUIT command, the client tells the server that the connection should be terminated.
int<1> 0x01 : COM_QUIT header.
Server terminates connection.
This page is licensed: CC BY-SA / Gnu FDL
This command asks the server to terminate a specific connection thread, functionally equivalent to the KILL statement.
Forces the server to terminate a specified connection.
int<1> 0xC COM_PROCESS_KILL.
process ID.
or .
This page is licensed: CC BY-SA / Gnu FDL
This command resets the session state (variables, tables, etc.) to its initial values without closing the connection.
COM_RESET_CONNECTION resets a connection without reauthentication.
The command does this:
Roll back any open transactions.
Reset transaction isolation level.
Delete user variables.
Remove temporary tables.
Remove all PREPARE statements.
Database will NOT be reset to initial value.
int<1> 0x1f : COM_RESET_CONNECTION Header
This page is licensed: CC BY-SA / Gnu FDL
int<2> option.
MYSQL_OPTION_MULTI_STATEMENTS_ON
0
MYSQL_OPTION_MULTI_STATEMENTS_OFF
1
EOF Packet on success or ERR packet.
This page is licensed: CC BY-SA / Gnu FDL
Constant
Value
SHUTDOWN_DEFAULT
0
This command sends an SQL statement to the server for execution immediately, without the prepare/execute steps.
With the COM_QUERY command, the client sends the server an SQL statement to be executed immediately.
int<1> 0x03 : COM_QUERY header.
SQL statement.
The SQL statement should be properly escaped. The escape character is usually a backslash '' = 0x5c. However, if the status flag returned by the last had the NO_BACKSLASH_ESCAPES bit set, the escape character is a single quote (' = 0x60).
If the escape character is a backslash, the following characters are escaped:
Single quote (' = 0x60).
Backslash (\ = 0x5c).
Double quote (" = 0x22
If the escape character is a single quote, only the single quote (' = 0x60) can be escaped.
The server can answer with 4 different responses that can be differentiated by the first byte (packet header):
0xFF - if any error occurs.
0x00 - when query execution works without result set.
0xFB - if the query was LOCAL INFILE ....
This page is licensed: CC BY-SA / Gnu FDL
Null character (0x00).
Or a result set, when the query returns results (in case of a SELECT query, for example).
1b 00 00 00 03 44 52 4f 50 20 54 41 42 4c 45 20
.....DROP TABLE
49 46 20 45 58 49 53 54 53 20 62 75 6c 6b 31
IF EXISTS bulk1
This command creates a new database on the server, functionally equivalent to the SQL statement CREATE DATABASE.
This page is licensed: CC BY-SA / Gnu FDL