在 MySQL 安装中有许多不同的程序。本节提供它们的简要概述。后续章节将对每个程序提供更详细的描述,但 NDB Cluster 程序除外。每个程序的描述都说明了其调用语法及支持的选项。第 25.5 节,“NDB Cluster 程序”描述了 NDB Cluster 特有的程序。There are many different programs in a MySQL installation. This section provides a brief overview of them. Later sections provide a more detailed description of each one, with the exception of NDB Cluster programs. Each program's description indicates its invocation syntax and the options that it supports. Section 25.5, “NDB Cluster Programs”, describes programs specific to NDB Cluster.
大多数 MySQL 发行版包含所有这些程序,除了那些特定于平台的程序。(例如,服务器启动脚本在 Windows 上不使用。)例外的是 RPM 发行版更加专业化。服务器有一个 RPM,客户端程序有另一个,依此类推。如果您发现缺少一个或多个程序,请参见 第 2 章,安装 MySQL,了解发行版类型及其包含内容。可能是您使用的发行版未包含所有程序,您需要安装额外的软件包。Most MySQL distributions include all of these programs, except for those programs that are platform-specific. (For example, the server startup scripts are not used on Windows.) The exception is that RPM distributions are more specialized. There is one RPM for the server, another for client programs, and so forth. If you appear to be missing one or more programs, see Chapter 2, Installing MySQL, for information on types of distributions and what they contain. It may be that you have a distribution that does not include all programs and you need to install an additional package.
每个 MySQL 程序都有许多不同的选项。大多数程序提供一个 --help 选项,你可以使用它来获取程序不同选项的说明。例如,试试 mysql --help。Each MySQL program takes many different options. Most programs
provide a --help option that you can use to get a
description of the program's different options. For example, try
mysql --help.
你可以通过在命令行或选项文件中指定选项来覆盖 MySQL 程序的默认选项值。有关调用程序和指定程序选项的一般信息,请参见 第 6.2 节,“使用 MySQL 程序”。You can override default option values for MySQL programs by specifying options on the command line or in an option file. See Section 6.2, “Using MySQL Programs”, for general information on invoking programs and specifying program options.
MySQL 服务器,mysqld,是 MySQL 安装中执行大部分工作的主要程序。服务器配有一些相关的脚本,帮助您启动和停止服务器:The MySQL server, mysqld, is the main program that does most of the work in a MySQL installation. The server is accompanied by several related scripts that assist you in starting and stopping the server:
SQL 守护进程(即 MySQL 服务器)。要使用客户端程序,mysqld 必须运行,因为客户端通过连接服务器来访问数据库。参见 第 6.3.1 节,“mysqld — MySQL 服务器”。The SQL daemon (that is, the MySQL server). To use client programs, mysqld must be running, because clients gain access to databases by connecting to the server. See Section 6.3.1, “mysqld — The MySQL Server”.
一个服务器启动脚本。mysqld_safe 尝试启动 mysqld。参见 第 6.3.2 节,“mysqld_safe — MySQL 服务器启动脚本”。A server startup script. mysqld_safe attempts to start mysqld. See Section 6.3.2, “mysqld_safe — MySQL Server Startup Script”.
服务器启动脚本。该脚本用于使用 System V 风格运行目录的系统,这些目录包含针对特定运行级别启动系统服务的脚本。它调用 mysqld_safe 来启动 MySQL 服务器。参见 第 6.3.3 节,“mysql.server — MySQL 服务器启动脚本”。A server startup script. This script is used on systems that use System V-style run directories containing scripts that start system services for particular run levels. It invokes mysqld_safe to start the MySQL server. See Section 6.3.3, “mysql.server — MySQL Server Startup Script”.
一个可以启动或停止系统上安装的多个服务器的服务器启动脚本。请参阅第 6.3.4 节,“mysqld_multi — 管理多个 MySQL 服务器”。A server startup script that can start or stop multiple servers installed on the system. See Section 6.3.4, “mysqld_multi — Manage Multiple MySQL Servers”.
在 MySQL 安装或升级期间,有几个程序会执行设置操作:Several programs perform setup operations during MySQL installation or upgrading:
此程序在 MySQL 构建/安装过程中使用。它从错误源文件编译错误消息文件。请参阅 第 6.4.1 节,“comp_err — 编译 MySQL 错误消息文件”。This program is used during the MySQL build/installation process. It compiles error message files from the error source files. See Section 6.4.1, “comp_err — Compile MySQL Error Message File”.
mysql_secure_installation mysql_secure_installation
该程序使您能够提高 MySQL 安装的安全性。参见 第 6.4.2 节,“mysql_secure_installation — 提高 MySQL 安装安全性”。This program enables you to improve the security of your MySQL installation. See Section 6.4.2, “mysql_secure_installation — Improve MySQL Installation Security”.
mysql_tzinfo_to_sql mysql_tzinfo_to_sql
该程序使用主机系统的 zoneinfo 数据库(描述时区的文件集)的内容加载
mysql数据库中的时区表。参见 第 6.4.3 节,“mysql_tzinfo_to_sql — 加载时区表”。This program loads the time zone tables in themysqldatabase using the contents of the host system zoneinfo database (the set of files describing time zones). See Section 6.4.3, “mysql_tzinfo_to_sql — Load the Time Zone Tables”.
连接到 MySQL 服务器的 MySQL 客户端程序:MySQL client programs that connect to the MySQL server:
用于交互式输入 SQL 语句或从文件以批处理模式执行 SQL 语句的命令行工具。参见 第 6.5.1 节,“mysql — MySQL 命令行客户端”。The command-line tool for interactively entering SQL statements or executing them from a file in batch mode. See Section 6.5.1, “mysql — The MySQL Command-Line Client”.
一个执行管理操作的客户端,例如创建或删除数据库、重新加载授权表、将表刷新到磁盘以及重新打开日志文件。mysqladmin 也可以用于从服务器检索版本、进程和状态信息。请参见 第 6.5.2 节,“mysqladmin — MySQL 服务器管理程序”。A client that performs administrative operations, such as creating or dropping databases, reloading the grant tables, flushing tables to disk, and reopening log files. mysqladmin can also be used to retrieve version, process, and status information from the server. See Section 6.5.2, “mysqladmin — A MySQL Server Administration Program”.
一个表维护客户端,用于检查、修复、分析和优化表。请参见 第 6.5.3 节,“mysqlcheck — 表维护程序”。A table-maintenance client that checks, repairs, analyzes, and optimizes tables. See Section 6.5.3, “mysqlcheck — A Table Maintenance Program”.
一个将 MySQL 数据库导出到文件的客户端,格式可以是 SQL、文本或 XML。请参见 第 6.5.4 节,“mysqldump — 数据库备份程序”。A client that dumps a MySQL database into a file as SQL, text, or XML. See Section 6.5.4, “mysqldump — A Database Backup Program”.
一个客户端使用
LOAD DATA将文本文件导入到各自的表中。请参见 第 6.5.5 节,“mysqlimport — 数据导入程序”。A client that imports text files into their respective tables usingLOAD DATA. See Section 6.5.5, “mysqlimport — A Data Import Program”.MySQL Shell 是 MySQL 服务器的高级客户端和代码编辑器。请参阅 MySQL Shell 8.4。除了提供的 SQL 功能外,类似于 mysql,MySQL Shell 还提供 JavaScript 和 Python 的脚本功能,并包括用于操作 MySQL 的 API。X DevAPI 使您能够处理关系数据和文档数据,详见 第 22 章,将 MySQL 用作文档存储。AdminAPI 使您能够管理 InnoDB 集群,详见 MySQL AdminAPI。MySQL Shell is an advanced client and code editor for MySQL Server. See MySQL Shell 8.4. In addition to the provided SQL functionality, similar to mysql, MySQL Shell provides scripting capabilities for JavaScript and Python and includes APIs for working with MySQL. X DevAPI enables you to work with both relational and document data, see Chapter 22, Using MySQL as a Document Store. AdminAPI enables you to work with InnoDB Cluster, see MySQL AdminAPI.
一个显示数据库、表、列和索引信息的客户端。请参阅 第 6.5.6 节,“mysqlshow — 显示数据库、表和列信息”。A client that displays information about databases, tables, columns, and indexes. See Section 6.5.6, “mysqlshow — Display Database, Table, and Column Information”.
一个旨在模拟 MySQL 服务器客户端负载并报告每个阶段时间的客户端。它的工作方式就像多个客户端正在访问服务器。见 第 6.5.7 节,“mysqlslap — 负载模拟客户端”。A client that is designed to emulate client load for a MySQL server and report the timing of each stage. It works as if multiple clients are accessing the server. See Section 6.5.7, “mysqlslap — A Load Emulation Client”.
MySQL 管理和实用程序:MySQL administrative and utility programs:
一个离线
InnoDB文件校验工具。参见 第 6.6.2 节,“innochecksum — 离线 InnoDB 文件校验工具”。An offlineInnoDBoffline file checksum utility. See Section 6.6.2, “innochecksum — Offline InnoDB File Checksum Utility”.一个用于显示
MyISAM表中全文索引信息的工具。参见 第 6.6.3 节,“myisam_ftdump — 显示全文索引信息”。A utility that displays information about full-text indexes inMyISAMtables. See Section 6.6.3, “myisam_ftdump — Display Full-Text Index information”.一个用于描述、检查、优化和修复
MyISAM表的工具。参见 第 6.6.4 节,“myisamchk — MyISAM 表维护工具”。A utility to describe, check, optimize, and repairMyISAMtables. See Section 6.6.4, “myisamchk — MyISAM Table-Maintenance Utility”.一个处理
MyISAM日志文件内容的工具。参见 第 6.6.5 节,“myisamlog — 显示 MyISAM 日志文件内容”。A utility that processes the contents of aMyISAMlog file. See Section 6.6.5, “myisamlog — Display MyISAM Log File Contents”.一个将
MyISAM表压缩以生成更小的只读表的实用程序。见 第 6.6.6 节,“myisampack — 生成压缩的只读 MyISAM 表”。A utility that compressesMyISAMtables to produce smaller read-only tables. See Section 6.6.6, “myisampack — Generate Compressed, Read-Only MyISAM Tables”.mysql_config_editor mysql_config_editor
一个允许你将认证凭据存储在名为
.mylogin.cnf的安全加密登录路径文件中的实用程序。见 第 6.6.7 节,“mysql_config_editor — MySQL 配置工具”。A utility that enables you to store authentication credentials in a secure, encrypted login path file named.mylogin.cnf. See Section 6.6.7, “mysql_config_editor — MySQL Configuration Utility”.mysql_migrate_keyringmysql_migrate_keyring
一个用于在一个钥匙环组件和另一个组件之间迁移密钥的工具。请参阅 第 6.6.8 节,“mysql_migrate_keyring — 钥匙环密钥迁移工具”。A utility for migrating keys between one keyring component and another. See Section 6.6.8, “mysql_migrate_keyring — Keyring Key Migration Utility”.
一个用于读取二进制日志中语句的工具。二进制日志文件中包含的已执行语句日志可以帮助从崩溃中恢复。参见 第 6.6.9 节,“mysqlbinlog — 二进制日志文件处理工具”。A utility for reading statements from a binary log. The log of executed statements contained in the binary log files can be used to help recover from a crash. See Section 6.6.9, “mysqlbinlog — Utility for Processing Binary Log Files”.
一个用于读取和汇总慢查询日志内容的工具。参见 第 6.6.10 节,“mysqldumpslow — 汇总慢查询日志文件”。A utility to read and summarize the contents of a slow query log. See Section 6.6.10, “mysqldumpslow — Summarize Slow Query Log Files”.
MySQL 程序开发工具:MySQL program-development utilities:
一个 shell 脚本,用于生成编译 MySQL 程序所需的选项值。参见 第 6.7.1 节,“mysql_config — 显示编译客户端的选项”。A shell script that produces the option values needed when compiling MySQL programs. See Section 6.7.1, “mysql_config — Display Options for Compiling Clients”.
my_print_defaults my_print_defaults
一个实用程序,用于显示选项文件中各选项组包含的选项。参见 第 6.7.2 节,“my_print_defaults — 显示选项文件中的选项”。A utility that shows which options are present in option groups of option files. See Section 6.7.2, “my_print_defaults — Display Options from Option Files”.
杂项工具:Miscellaneous utilities:
一个显示系统或 MySQL 错误代码含义的工具。参见 第 6.8.1 节,“perror — 显示 MySQL 错误信息”。A utility that displays the meaning of system or MySQL error codes. See Section 6.8.1, “perror — Display MySQL Error Message Information”.
Oracle 公司还提供了 MySQL Workbench 图形界面工具,用于管理 MySQL 服务器和数据库,创建、执行和评估查询,以及将其他关系数据库管理系统的模式和数据迁移到 MySQL 使用。Oracle Corporation also provides the MySQL Workbench GUI tool, which is used to administer MySQL servers and databases, to create, execute, and evaluate queries, and to migrate schemas and data from other relational database management systems for use with MySQL.
使用 MySQL 客户端/服务器库与服务器通信的 MySQL 客户端程序使用以下环境变量。MySQL client programs that communicate with the server using the MySQL client/server library use the following environment variables.
| 环境变量Environment Variable | 意义Meaning |
|---|---|
MYSQL_UNIX_PORT |
默认的 Unix 套接字文件;用于连接到 localhostThe default Unix socket file; used for connections to
localhost |
MYSQL_TCP_PORT |
默认端口号;用于 TCP/IP 连接The default port number; used for TCP/IP connections |
MYSQL_DEBUG |
调试时的调试跟踪选项Debug trace options when debugging |
TMPDIR |
创建临时表和文件的目录The directory where temporary tables and files are created |
有关 MySQL 程序使用的环境变量的完整列表,请参见 第 6.9 节,“环境变量”。For a full list of environment variables used by MySQL programs, see Section 6.9, “Environment Variables”.