8.4 中文镜像

MySQL 8.4 参考手册 · 中文镜像

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

打开官方英文原文 ↗

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

MySQL 8.4 参考手册 / 6 个 MySQL 程序 / 6.7 程序开发实用程序
中文点击中文段落可显示 / 隐藏英文原文本页译文覆盖 100%

6.7 程序开发工具6.7 Program Development Utilities

本节介绍了一些在开发 MySQL 程序时可能会发现有用的实用工具。This section describes some utilities that you may find useful when developing MySQL programs.

在 shell 脚本中,你可以使用 my_print_defaults 程序来解析选项文件,并查看给定程序将使用哪些选项。下面的示例显示了当请求显示 [client] 和 [mysql] 组中找到的选项时,my_print_defaults 可能产生的输出:In shell scripts, you can use the my_print_defaults program to parse option files and see what options would be used by a given program. The following example shows the output that my_print_defaults might produce when asked to show the options found in the [client] and [mysql] groups:

$> my_print_defaults client mysql
--port=3306
--socket=/tmp/mysql.sock
--no-auto-rehash

开发者注意:选项文件处理是在 C 客户端库中实现的,只需在命令行参数之前处理相应组中的所有选项。这对于使用多次指定选项最后实例的程序效果很好。如果你有一个 C 或 C 程序能处理多重指定选项但不读取选项文件,只需添加两行即可实现此功能。查看任何标准 MySQL 客户端的源代码,了解如何实现此功能。Note for developers: Option file handling is implemented in the C client library simply by processing all options in the appropriate group or groups before any command-line arguments. This works well for programs that use the last instance of an option that is specified multiple times. If you have a C or C++ program that handles multiply specified options this way but that doesn't read option files, you need add only two lines to give it that capability. Check the source code of any of the standard MySQL clients to see how to do this.

还有其他几种基于 C 客户端库的 MySQL 语言接口,其中一些提供了访问选项文件内容的方式。这些包括 Perl 和 Python。详情请参见您偏好的界面文档。Several other language interfaces to MySQL are based on the C client library, and some of them provide a way to access option file contents. These include Perl and Python. For details, see the documentation for your preferred interface.