8.4 中文镜像

MySQL 8.4 参考手册 · 中文镜像

正文为中文,英文原文默认隐藏。点击任意中文段落即可展开 / 收起对应英文原文。

打开官方英文原文 ↗

译文由机器翻译生成,仅供理解参考;有疑问请以官方英文原文为准。

中文点击中文段落可显示 / 隐藏英文原文本页译文覆盖 100%

7.9.2 调试 MySQL 客户端7.9.2 Debugging a MySQL Client

为了能够使用集成调试包调试 MySQL 客户端,您应该使用 -DWITH_DEBUG=1 配置 MySQL。参见 第 2.8.7 节,“MySQL 源配置选项”。To be able to debug a MySQL client with the integrated debug package, you should configure MySQL with -DWITH_DEBUG=1. See Section 2.8.7, “MySQL Source-Configuration Options”.

在运行客户端之前,您应该设置 MYSQL_DEBUG 环境变量:Before running a client, you should set the MYSQL_DEBUG environment variable:

$> MYSQL_DEBUG=d:t:O,/tmp/client.trace
$> export MYSQL_DEBUG

这将使客户端在 /tmp/client.trace 中生成跟踪文件。This causes clients to generate a trace file in /tmp/client.trace.

如果您的客户端代码有问题,您应该尝试使用一个已知可用的客户端连接到服务器并运行查询。可以通过以调试模式运行 mysql 来实现(假设您已编译了带调试功能的 MySQL):If you have problems with your own client code, you should attempt to connect to the server and run your query using a client that is known to work. Do this by running mysql in debugging mode (assuming that you have compiled MySQL with debugging on):

$> mysql --debug=d:t:O,/tmp/client.trace

这样在您提交错误报告时会提供有用的信息。参见 第 1.6 节,“如何报告错误或问题”。This provides useful information in case you mail a bug report. See Section 1.6, “How to Report Bugs or Problems”.

如果您的客户端在一些看似“合法”的代码处崩溃,您应该检查您的 mysql.h 头文件是否与您的 MySQL 库文件匹配。一个非常常见的错误是将来自旧 MySQL 安装的旧 mysql.h 文件与新的 MySQL 库一起使用。If your client crashes at some 'legal' looking code, you should check that your mysql.h include file matches your MySQL library file. A very common mistake is to use an old mysql.h file from an old MySQL installation with new MySQL library.