PDF (US Ltr) - 420.5Kb
PDF (A4) - 419.3Kb
MySQL 包含一个测试协议跟踪插件,用于说明此类插件可获得的信息,并作为编写其他协议跟踪插件的指南。要查看测试插件的工作原理,请使用 MySQL 源代码分发版;二进制分发版在构建时禁用测试插件。
通过使用 WITH_TEST_TRACE_PLUGIN
CMake 选项启用,可以启用测试协议跟踪插件。这将导致构建测试跟踪插件并让 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=