PDF (US Ltr) - 420.2Kb
PDF (A4) - 419.0Kb
MySQL 包含一个测试协议跟踪插件,用于说明此类插件可用的信息,并作为编写其他协议跟踪插件的指南。要查看测试插件的工作原理,请使用 MySQL 源代码分发版;二进制分发版在禁用测试插件的情况下构建。
通过使用 WITH_TEST_TRACE_PLUGIN
CMake 选项启用配置 MySQL 来启用测试协议跟踪插件。这会导致测试跟踪插件被构建并且 MySQL 客户端程序加载它,但插件默认情况下没有效果。使用以下环境变量控制插件
MYSQL_TEST_TRACE_DEBUG
: 将此变量设置为非 0 值,使测试插件在stderr
上生成诊断输出。MYSQL_TEST_TRACE_CRASH
: 将此变量设置为非 0 值,使测试插件在检测到无效跟踪事件时中止客户端程序。
注意
测试协议跟踪插件的诊断输出可能会泄露密码和其他敏感信息。
给定一个从源代码构建且启用了测试插件的 MySQL 安装,您可以查看 mysql 客户端和 MySQL 服务器之间通信的跟踪,如下所示
$> 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
要禁用跟踪输出,请执行以下操作
$> MYSQL_TEST_TRACE_DEBUG=