MySQL includes a test protocol trace plugin that serves to illustrate the information available from such plugins, and as a guide to writing other protocol trace plugins. To see how the test plugin works, use a MySQL source distribution; binary distributions are built with the test plugin disabled.
Enable the test protocol trace plugin by configuring MySQL
CMake option enabled. This causes the
test trace plugin to be built and MySQL client programs to
load it, but the plugin has no effect by default. Control
the plugin using these environment variables:
MYSQL_TEST_TRACE_DEBUG: Set this variable to a value other than 0 to cause the test plugin to produce diagnostic output on
MYSQL_TEST_TRACE_CRASH: Set this variable to a value other than 0 to cause the test plugin to abort the client program if it detects an invalid trace event.
Diagnostic output from the test protocol trace plugin can disclose passwords and other sensitive information.
Given a MySQL installation built from source with the test plugin enabled, you can see a trace of the communication between the mysql client and the MySQL server as follows:
shell> export MYSQL_TEST_TRACE_DEBUG=1 shqll> mysql test_trace: Test trace plugin initialized test_trace: Starting tracing in stage CONNECTING test_trace: stage: CONNECTING, event: CONNECTING test_trace: stage: CONNECTING, event: CONNECTED test_trace: stage: WAIT_FOR_INIT_PACKET, event: READ_PACKET test_trace: stage: WAIT_FOR_INIT_PACKET, event: PACKET_RECEIVED test_trace: packet received: 87 bytes 0A 35 2E 37 2E 33 2D 6D 31 33 2D 64 65 62 75 67 .5.7.3-m13-debug 2D 6C 6F 67 00 04 00 00 00 2B 7C 4F 55 3F 79 67 -log.....+|OU?yg test_trace: 004: stage: WAIT_FOR_INIT_PACKET, event: INIT_PACKET_RECEIVED test_trace: 004: stage: AUTHENTICATE, event: AUTH_PLUGIN test_trace: 004: Using authentication plugin: mysql_native_password test_trace: 004: stage: AUTHENTICATE, event: SEND_AUTH_RESPONSE test_trace: 004: sending packet: 188 bytes 85 A6 7F 00 00 00 00 01 21 00 00 00 00 00 00 00 .?......!....... 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ ... mysql> quit test_trace: 008: stage: READY_FOR_COMMAND, event: SEND_COMMAND test_trace: 008: QUIT test_trace: 008: stage: READY_FOR_COMMAND, event: PACKET_SENT test_trace: 008: packet sent: 0 bytes test_trace: 008: stage: READY_FOR_COMMAND, event: DISCONNECTED test_trace: 008: Connection closed test_trace: 008: Tracing connection has ended Bye test_trace: Test trace plugin de-initialized
To disable trace output, do this: