8.4 中文镜像

MySQL 8.4 参考手册 · 中文镜像

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

打开官方英文原文 ↗

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

MySQL 8.4 参考手册 / 6 个 MySQL 程序 / 6.7 程序开发实用程序 / 6.7.1 mysql_config — 显示编译客户端的选项
中文点击中文段落可显示 / 隐藏英文原文本页译文覆盖 62%

6.7.1 mysql_config — 显示编译客户端的选项6.7.1 mysql_config — Display Options for Compiling Clients

mysql_config 为您提供编译 MySQL 客户端并将其连接到 MySQL 的有用信息。它是一个 shell 脚本,因此仅在 Unix 和类 Unix 系统上可用。mysql_config provides you with useful information for compiling your MySQL client and connecting it to MySQL. It is a shell script, so it is available only on Unix and Unix-like systems.

Note

pkg-config 可以作为 mysql_config 的替代方案,用于获取编译 MySQL 应用程序所需的编译器标志或链接库等信息。更多信息,请参见 使用 pkg-config 构建 C API 客户端程序。pkg-config can be used as an alternative to mysql_config for obtaining information such as compiler flags or link libraries required to compile MySQL applications. For more information, see Building C API Client Programs Using pkg-config.

mysql_config 支持以下选项。mysql_config supports the following options.

  • --cflags

    用于查找包含文件的 C 编译器标志以及在编译libmysqlclient库时使用的关键编译器标志和定义。返回的选项与创建库时使用的特定编译器相关,并可能与您自己编译器的设置冲突。使用--include以获得仅包含包含路径的更通用选项。C Compiler flags to find include files and critical compiler flags and defines used when compiling the libmysqlclient library. The options returned are tied to the specific compiler that was used when the library was created and might clash with the settings for your own compiler. Use --include for more portable options that contain only include paths.

  • --cxxflags

    类似于--cflags,但是用于 C++编译器标志。Like --cflags, but for C++ compiler flags.

  • --include

    用于查找 MySQL 包含文件的编译器选项。Compiler options to find MySQL include files.

  • --libs

    与 MySQL 客户端库链接所需的库和选项。Libraries and options required to link with the MySQL client library.

  • --libs_r

    与线程安全的 MySQL 客户端库链接所需的库和选项。在 MySQL 8.4 中,所有客户端库都是线程安全的,因此无需使用此选项。--libs 选项在所有情况下都可以使用。Libraries and options required to link with the thread-safe MySQL client library. In MySQL 8.4, all client libraries are thread-safe, so this option need not be used. The --libs option can be used in all cases.

  • --plugindir

    默认插件目录路径名称,在配置 MySQL 时定义。The default plugin directory path name, defined when configuring MySQL.

  • --port

    默认的 TCP/IP 端口号,在配置 MySQL 时定义。The default TCP/IP port number, defined when configuring MySQL.

  • --socket

    默认的 Unix 套接字文件,在配置 MySQL 时定义。The default Unix socket file, defined when configuring MySQL.

  • --variable=var_name

    显示指定配置变量的值。允许的 var_name 值为 pkgincludedir(头文件目录)、pkglibdir(库目录)和 plugindir(插件目录)。Display the value of the named configuration variable. Permitted var_name values are pkgincludedir (the header file directory), pkglibdir (the library directory), and plugindir (the plugin directory).

  • --version

    MySQL 分发的版本号。Version number for the MySQL distribution.

如果你调用mysql_config而不加任何选项,它会显示它支持的所有选项及其值:If you invoke mysql_config with no options, it displays a list of all options that it supports, and their values:

$> mysql_config
Usage: ./mysql_config [OPTIONS]
Compiler: GNU 10.4.0

Options:
  --cflags         [-I/usr/local/mysql/include/mysql]
  --cxxflags       [-I/usr/local/mysql/include/mysql]
  --include        [-I/usr/local/mysql/include/mysql]
  --libs           [-L/usr/local/mysql/lib/mysql -lmysqlclient -lpthread -ldl  
                    -lssl  -lcrypto -lresolv -lm -lrt]
  --libs_r         [-L/usr/local/mysql/lib/mysql -lmysqlclient -lpthread -ldl  
                    -lssl  -lcrypto -lresolv -lm -lrt]
  --plugindir      [/usr/local/mysql/lib/plugin]
  --socket         [/tmp/mysql.sock]
  --port           [3306]
  --version        [8.4.0]
  --variable=VAR   VAR is one of:
          pkgincludedir [/usr/local/mysql/include]
          pkglibdir     [/usr/local/mysql/lib]
          plugindir     [/usr/local/mysql/lib/plugin]

你可以在命令行中使用mysql_config并用反引号包含它为特定选项生成的输出。例如,要编译和链接一个 MySQL 客户端程序,可以如下使用mysql_config:You can use mysql_config within a command line using backticks to include the output that it produces for particular options. For example, to compile and link a MySQL client program, use mysql_config as follows:

gcc -c `mysql_config --cflags` progname.c
gcc -o progname progname.o `mysql_config --libs`