mysqlslap 是一个诊断程序,用于模拟 MySQL 服务器的客户端负载,并报告每个阶段的时间。它的工作方式就像多个客户端同时访问服务器一样。mysqlslap is a diagnostic program designed to emulate client load for a MySQL server and to report the timing of each stage. It works as if multiple clients are accessing the server.
像这样调用 mysqlslap:Invoke mysqlslap like this:
mysqlslap [options]
一些选项,例如 --create 或 --query 允许你指定一个包含 SQL 语句的字符串或一个包含语句的文件。如果你指定一个文件,默认情况下,它必须每行包含一个语句。(也就是说,隐式语句分隔符是换行符。)使用 --delimiter 选项来指定不同的分隔符,这使你可以指定跨多行的语句或在单行中放置多个语句。文件中不能包含注释;mysqlslap 不理解它们。Some options such as --create
or --query enable you to
specify a string containing an SQL statement or a file
containing statements. If you specify a file, by default it must
contain one statement per line. (That is, the implicit statement
delimiter is the newline character.) Use the
--delimiter option to specify
a different delimiter, which enables you to specify statements
that span multiple lines or place multiple statements on a
single line. You cannot include comments in a file;
mysqlslap does not understand them.
mysqlslap 分三个阶段运行:mysqlslap runs in three stages:
创建模式、表,并可选择创建用于测试的任何存储程序或数据。此阶段使用单个客户端连接。Create schema, table, and optionally any stored programs or data to use for the test. This stage uses a single client connection.
运行负载测试。此阶段可以使用多个客户端连接。Run the load test. This stage can use many client connections.
清理(断开连接,如果指定则删除表)。此阶段使用单个客户端连接。Clean up (disconnect, drop table if specified). This stage uses a single client connection.
示例:Examples:
提供您自己的创建和查询 SQL 语句,使用 50 个客户端进行查询,每个客户端执行 200 次选择(将在单行中输入命令):Supply your own create and query SQL statements, with 50 clients querying and 200 selects for each (enter the command on a single line):
mysqlslap --delimiter=";" --create="CREATE TABLE a (b int);INSERT INTO a VALUES (23)" --query="SELECT * FROM a" --concurrency=50 --iterations=200
让 mysqlslap 使用一个包含两列 INT 和三列 VARCHAR 的表来构建查询 SQL 语句。使用五个客户端,每个客户端查询 20 次。不要创建表或插入数据(即使用上一次测试的模式和数据):Let mysqlslap build the query SQL statement
with a table of two INT columns
and three VARCHAR columns. Use
five clients querying 20 times each. Do not create the table or
insert the data (that is, use the previous test's schema and
data):
mysqlslap --concurrency=5 --iterations=20 --number-int-cols=2 --number-char-cols=3 --auto-generate-sql
告诉程序从指定的文件加载创建、插入和查询 SQL 语句,其中 create.sql 文件包含多个以 ';' 分隔的表创建语句,以及多个以 ';' 分隔的插入语句。--query 文件应包含多个以 ';' 分隔的查询语句。运行所有加载语句,然后使用五个客户端(每个客户端运行五次)运行查询文件中的所有查询:Tell the program to load the create, insert, and query SQL
statements from the specified files, where the
create.sql file has multiple table creation
statements delimited by ';' and multiple
insert statements delimited by ';'. The
--query file should contain multiple queries
delimited by ';'. Run all the load
statements, then run all the queries in the query file with five
clients (five times each):
mysqlslap --concurrency=5 --iterations=5 --query=query.sql --create=create.sql --delimiter=";"
mysqlslap 支持以下选项,这些选项可以在命令行中指定,也可以在选项文件的 [mysqlslap] 和 [client] 组中指定。有关 MySQL 程序使用的选项文件的信息,请参见 第 6.2.2.2 节,“使用选项文件”。mysqlslap supports the following options,
which can be specified on the command line or in the
[mysqlslap] and [client]
groups of an option file. For information about option files
used by MySQL programs, see Section 6.2.2.2, “Using Option Files”.
表 6.16 mysqlslap 选项Table 6.16 mysqlslap Options
| 选项名称Option Name | 说明Description |
|---|---|
| --自动生成 SQL--auto-generate-sql | 当文件或命令选项中未提供时自动生成 SQL 语句Generate SQL statements automatically when they are not supplied in files or using command options |
| --自动生成 SQL 并添加自增--auto-generate-sql-add-autoincrement | 向自动生成的表添加 AUTO_INCREMENT 列Add AUTO_INCREMENT column to automatically generated tables |
| --自动生成 SQL 执行次数--auto-generate-sql-execute-number | 指定要自动生成的查询数量Specify how many queries to generate automatically |
| --自动生成 SQL GUID 主键--auto-generate-sql-guid-primary | 向自动生成的表添加基于 GUID 的主键Add a GUID-based primary key to automatically generated tables |
| --自动生成 SQL 负载类型--auto-generate-sql-load-type | 指定测试负载类型Specify the test load type |
| --自动生成 SQL 二级索引--auto-generate-sql-secondary-indexes | 指定要向自动生成的表中添加多少个二级索引Specify how many secondary indexes to add to automatically generated tables |
| --自动生成 SQL 唯一查询编号--auto-generate-sql-unique-query-number | 要为自动测试生成多少个不同的查询How many different queries to generate for automatic tests |
| --自动生成 SQL 唯一写入数量--auto-generate-sql-unique-write-number | 为 --auto-generate-sql-write-number 生成多少不同的查询How many different queries to generate for --auto-generate-sql-write-number |
| --自动生成 SQL 写入数量--auto-generate-sql-write-number | 每个线程要执行多少行插入How many row inserts to perform on each thread |
| --提交--commit | 在提交之前要执行多少条语句How many statements to execute before committing |
| --压缩--compress | 压缩客户端和服务器之间发送的所有信息Compress all information sent between client and server |
| --压缩算法--compression-algorithms | 允许用于连接服务器的压缩算法Permitted compression algorithms for connections to server |
| --并发--concurrency | 发出 SELECT 语句时要模拟的客户端数量Number of clients to simulate when issuing the SELECT statement |
| --创建--create | 包含用于创建表的语句的文件或字符串File or string containing the statement to use for creating the table |
| --创建数据库--create-schema | 运行测试的模式Schema in which to run the tests |
| --csv | 以逗号分隔值格式生成输出Generate output in comma-separated values format |
| --调试--debug | 写调试日志Write debugging log |
| --调试检查--debug-check | 程序退出时打印调试信息Print debugging information when program exits |
| --调试信息--debug-info | 在程序退出时打印调试信息、内存和 CPU 统计信息Print debugging information, memory, and CPU statistics when program exits |
| --默认认证--default-auth | 要使用的身份验证插件Authentication plugin to use |
| --额外默认文件--defaults-extra-file | 除了常规选项文件外,读取指定名称的选项文件Read named option file in addition to usual option files |
| --默认文件--defaults-file | 仅读取指定的选项文件Read only named option file |
| --默认组后缀--defaults-group-suffix | 选项组后缀值Option group suffix value |
| --分隔符--delimiter | 在 SQL 语句中使用的分隔符Delimiter to use in SQL statements |
| --分离--detach | 在每 N 条语句后,断开连接(关闭并重新打开)Detach (close and reopen) each connection after each N statements |
| --启用明文插件--enable-cleartext-plugin | 启用明文身份验证插件Enable cleartext authentication plugin |
| --引擎--engine | 用于创建表的存储引擎Storage engine to use for creating the table |
| --获取服务器公钥--get-server-public-key | 从服务器请求 RSA 公钥Request RSA public key from server |
| --帮助--help | 显示帮助信息并退出Display help message and exit |
| --主机--host | MySQL 服务器所在的主机Host on which MySQL server is located |
| --迭代次数--iterations | 运行测试的次数Number of times to run the tests |
| --登录路径--login-path | 从 .mylogin.cnf 读取登录路径选项Read login path options from .mylogin.cnf |
| --无默认值--no-defaults | 不读取任何选项文件Read no option files |
| --无删除--no-drop | 不要删除在测试运行期间创建的任何模式Do not drop any schema created during the test run |
| --无登录路径--no-login-paths | 不要从登录路径文件中读取登录路径Do not read login paths from the login path file |
| --字符列数--number-char-cols | 如果指定 --auto-generate-sql,要使用的 VARCHAR 列数Number of VARCHAR columns to use if --auto-generate-sql is specified |
| --整数列数--number-int-cols | 如果指定 --auto-generate-sql,要使用的 INT 列数Number of INT columns to use if --auto-generate-sql is specified |
| --查询次数--number-of-queries | 将每个客户限制在大约此数量的查询Limit each client to approximately this number of queries |
| --仅打印--only-print | 不要连接到数据库。mysqlslap 只是打印它本来会做的事情Do not connect to databases. mysqlslap only prints what it would have done |
| --密码--password | 连接服务器时使用的密码Password to use when connecting to server |
| --密码 1--password1 | 首次多因素身份验证密码,用于连接服务器First multifactor authentication password to use when connecting to server |
| --密码 2--password2 | 连接服务器时使用的第二个多因素认证密码Second multifactor authentication password to use when connecting to server |
| --密码 3--password3 | 连接服务器时使用的第三个多因素认证密码Third multifactor authentication password to use when connecting to server |
| --管道--pipe | 使用命名管道连接到服务器(仅限 Windows)Connect to server using named pipe (Windows only) |
| --插件目录--plugin-dir | 插件安装的目录Directory where plugins are installed |
| --端口--port | 连接的 TCP/IP 端口号TCP/IP port number for connection |
| --查询后操作--post-query | 包含在测试完成后要执行的语句的文件或字符串File or string containing the statement to execute after the tests have completed |
| --系统后--post-system | 在测试完成后使用 system() 执行的字符串String to execute using system() after the tests have completed |
| --预查询--pre-query | 在运行测试之前要执行的语句所在的文件或字符串File or string containing the statement to execute before running the tests |
| --系统前--pre-system | 在运行测试之前使用 system() 执行的字符串String to execute using system() before running the tests |
| --打印默认值--print-defaults | 打印默认选项Print default options |
| --协议--protocol | 要使用的传输协议Transport protocol to use |
| --查询--query | 包含用于检索数据的 SELECT 语句的文件或字符串File or string containing the SELECT statement to use for retrieving data |
| --服务器公钥路径--server-public-key-path | 包含 RSA 公钥的文件路径名称Path name to file containing RSA public key |
| --共享内存基础名称--shared-memory-base-name | 共享内存连接的共享内存名称(仅限 Windows)Shared-memory name for shared-memory connections (Windows only) |
| --静默--silent | 静音模式Silent mode |
| --套接字--socket | 要使用的 Unix 套接字文件或 Windows 命名管道Unix socket file or Windows named pipe to use |
| --SQL 模式--sql-mode | 为客户端会话设置 SQL 模式Set SQL mode for client session |
| --ssl-ca | 包含受信任的 SSL 证书颁发机构列表的文件File that contains list of trusted SSL Certificate Authorities |
| --ssl-capath | 包含受信任的 SSL 证书颁发机构证书文件的目录Directory that contains trusted SSL Certificate Authority certificate files |
| --ssl-cert | 包含 X.509 证书的文件File that contains X.509 certificate |
| --ssl-加密套件--ssl-cipher | 连接加密的允许密码Permissible ciphers for connection encryption |
| --ssl-证书吊销列表--ssl-crl | 包含证书吊销列表的文件File that contains certificate revocation lists |
| --ssl-证书吊销列表路径--ssl-crlpath | 包含证书吊销列表文件的目录Directory that contains certificate revocation-list files |
| --ssl-fips 模式--ssl-fips-mode | 是否在客户端启用 FIPS 模式Whether to enable FIPS mode on client side |
| --ssl-密钥--ssl-key | 包含 X.509 密钥的文件File that contains X.509 key |
| --ssl-模式--ssl-mode | 与服务器连接的期望安全状态Desired security state of connection to server |
| --ssl-会话数据--ssl-session-data | 包含 SSL 会话数据的文件File that contains SSL session data |
| --ssl-会话数据-在重用失败时继续--ssl-session-data-continue-on-failed-reuse | 如果会话重用失败,是否建立连接Whether to establish connections if session reuse fails |
| --tls-加密套件--tls-ciphersuites | 允许的用于加密连接的 TLSv1.3 加密套件Permissible TLSv1.3 ciphersuites for encrypted connections |
| --tls-sni-服务器名称--tls-sni-servername | 由客户端提供的服务器名称Server name supplied by the client |
| --TLS 版本--tls-version | 允许用于加密连接的 TLS 协议Permissible TLS protocols for encrypted connections |
| --用户--user | 连接服务器时使用的 MySQL 用户名MySQL user name to use when connecting to server |
| --详细--verbose | 详细模式Verbose mode |
| --版本--version | 显示版本信息并退出Display version information and exit |
| --zstd 压缩级别--zstd-compression-level | 用于与服务器进行 zstd 压缩连接的压缩级别Compression level for connections to server that use zstd compression |
命令行格式Command-Line Format --help--help显示帮助信息并退出。Display a help message and exit.
--auto-generate-sql,-a--auto-generate-sql,-a命令行格式Command-Line Format --auto-generate-sql--auto-generate-sql类型Type 布尔Boolean 默认值Default Value FALSE当文件或命令选项中未提供时,自动生成 SQL 语句。Generate SQL statements automatically when they are not supplied in files or using command options.
--auto-generate-sql-add-autoincrement--auto-generate-sql-add-autoincrement命令行格式Command-Line Format --auto-generate-sql-add-autoincrement--auto-generate-sql-add-autoincrement类型Type 布尔Boolean 默认值Default Value FALSE向自动生成的表添加一个
AUTO_INCREMENT列。Add anAUTO_INCREMENTcolumn to automatically generated tables.--auto-generate-sql-execute-number=N命令行格式Command-Line Format --auto-generate-sql-execute-number=#--auto-generate-sql-execute-number=#类型Type 数字Numeric 指定要自动生成的查询数量。Specify how many queries to generate automatically.
--auto-generate-sql-guid-primary命令行格式Command-Line Format --auto-generate-sql-guid-primary--auto-generate-sql-guid-primary类型Type 布尔Boolean 默认值Default Value FALSE向自动生成的表添加基于 GUID 的主键。Add a GUID-based primary key to automatically generated tables.
--auto-generate-sql-load-type=type--auto-generate-sql-load-type=type命令行格式Command-Line Format --auto-generate-sql-load-type=type--auto-generate-sql-load-type=type类型Type 枚举Enumeration 默认值Default Value mixedmixed有效值Valid Values readreadwritewritekeykeyupdateupdatemixedmixed指定测试负载类型。允许的值为
read(扫描表)、write(插入表)、key(读取主键)、update(更新主键)或mixed(一半插入,一半扫描选择)。默认值为mixed。Specify the test load type. The permissible values areread(scan tables),write(insert into tables),key(read primary keys),update(update primary keys), ormixed(half inserts, half scanning selects). The default ismixed.--auto-generate-sql-secondary-indexes=N命令行格式Command-Line Format --auto-generate-sql-secondary-indexes=#类型Type 数字Numeric 默认值Default Value 0指定要向自动生成的表中添加多少个二级索引。默认情况下,不会添加任何索引。Specify how many secondary indexes to add to automatically generated tables. By default, none are added.
--auto-generate-sql-unique-query-number=N--auto-generate-sql-unique-query-number=N命令行格式Command-Line Format --auto-generate-sql-unique-query-number=#--auto-generate-sql-unique-query-number=#类型Type 数字Numeric 默认值Default Value 10用于自动测试生成多少不同的查询。例如,如果你运行一个执行 1000 次选择的
key测试,你可以使用这个选项并设置为 1000 来运行 1000 个唯一查询,或者设置为 50 来执行 50 个不同的选择。默认值是 10。How many different queries to generate for automatic tests. For example, if you run akeytest that performs 1000 selects, you can use this option with a value of 1000 to run 1000 unique queries, or with a value of 50 to perform 50 different selects. The default is 10.--auto-generate-sql-unique-write-number=N--auto-generate-sql-unique-write-number=N命令行格式Command-Line Format --auto-generate-sql-unique-write-number=#--auto-generate-sql-unique-write-number=#类型Type 数字Numeric 默认值Default Value 10生成多少不同的查询,适用于
--auto-generate-sql-write-number。默认值是 10。How many different queries to generate for--auto-generate-sql-write-number. The default is 10.--auto-generate-sql-write-number=N命令行格式Command-Line Format --auto-generate-sql-write-number=#类型Type 数字Numeric 默认值Default Value 100要执行多少行插入。默认值是 100。How many row inserts to perform. The default is 100.
命令行格式Command-Line Format --commit=#--commit=#类型Type 数字Numeric 默认值Default Value 0在提交之前要执行多少条语句。默认值是 0(不进行提交)。How many statements to execute before committing. The default is 0 (no commits are done).
--compress,-C命令行格式Command-Line Format --compress[={OFF|ON}]--compress[={OFF|ON}]已弃用Deprecated 是Yes 类型Type 布尔Boolean 默认值Default Value OFFOFF如果可能,压缩客户端与服务器之间发送的所有信息。参见 第 6.2.8 节,“连接压缩控制”。Compress all information sent between the client and the server if possible. See Section 6.2.8, “Connection Compression Control”.
此选项已被弃用。预计将在 MySQL 的未来版本中移除。请参阅 配置遗留连接压缩。This option is deprecated. Expect it to be removed in a future version of MySQL. See Configuring Legacy Connection Compression.
--compression-algorithms=value--compression-algorithms=value命令行格式Command-Line Format --compression-algorithms=value--compression-algorithms=value类型Type 设置Set 默认值Default Value uncompresseduncompressed有效值Valid Values zlibzstduncompresseduncompressed允许用于与服务器连接的压缩算法。可用算法与
protocol_compression_algorithms系统变量的算法相同。默认值为uncompressed。The permitted compression algorithms for connections to the server. The available algorithms are the same as for theprotocol_compression_algorithmssystem variable. The default value isuncompressed.更多信息,请参阅 第 6.2.8 节,“连接压缩控制”。For more information, see Section 6.2.8, “Connection Compression Control”.
--concurrency=,N-cN命令行格式Command-Line Format --concurrency=#类型Type 数字Numeric 要模拟的并行客户端数量。The number of parallel clients to simulate.
命令行格式Command-Line Format --create=value--create=value类型Type 字符串String 包含用于创建表的语句的文件或字符串。The file or string containing the statement to use for creating the table.
--create-schema=value--create-schema=value命令行格式Command-Line Format --create-schema=value--create-schema=value类型Type 字符串String 运行测试的模式。The schema in which to run the tests.
Note如果同时使用了
--auto-generate-sql选项,mysqlslap将在测试运行结束时删除模式。要避免这种情况,请同时使用--no-drop选项。If the--auto-generate-sqloption is also given, mysqlslap drops the schema at the end of the test run. To avoid this, use the--no-dropoption as well.--csv[=file_name]--csv[=file_name]命令行格式Command-Line Format --csv=[file]--csv=[file]类型Type 文件名File name 以逗号分隔值格式生成输出。如果未给定文件,输出将发送到命名文件或标准输出。Generate output in comma-separated values format. The output goes to the named file, or to the standard output if no file is given.
--debug[=debug_options],-# [debug_options]--debug[=,debug_options]-# [debug_options]命令行格式Command-Line Format --debug[=debug_options]--debug[=debug_options]类型Type 字符串String 默认值Default Value d:t:o,/tmp/mysqlslap.trace写入调试日志。一个典型的
debug_options字符串是d:t:o,。默认值是file_named:t:o,/tmp/mysqlslap.trace。Write a debugging log. A typicaldebug_optionsstring isd:t:o,. The default isfile_named:t:o,/tmp/mysqlslap.trace.此选项仅在 MySQL 使用
WITH_DEBUG构建时可用。Oracle 提供的 MySQL 发行版二进制文件 未 使用此选项构建。This option is available only if MySQL was built usingWITH_DEBUG. MySQL release binaries provided by Oracle are not built using this option.命令行格式Command-Line Format --debug-check类型Type 布尔Boolean 默认值Default Value FALSE程序退出时打印一些调试信息。Print some debugging information when the program exits.
此选项仅在 MySQL 使用
WITH_DEBUG构建时可用。Oracle 提供的 MySQL 发行版二进制文件 未 使用此选项构建。This option is available only if MySQL was built usingWITH_DEBUG. MySQL release binaries provided by Oracle are not built using this option.--debug-info,-T命令行格式Command-Line Format --debug-info类型Type 布尔Boolean 默认值Default Value FALSE在程序退出时打印调试信息以及内存和 CPU 使用情况统计。Print debugging information and memory and CPU usage statistics when the program exits.
此选项仅在 MySQL 使用
WITH_DEBUG构建时可用。Oracle 提供的 MySQL 发行版二进制文件 未 使用此选项构建。This option is available only if MySQL was built usingWITH_DEBUG. MySQL release binaries provided by Oracle are not built using this option.--default-auth=plugin--default-auth=plugin命令行格式Command-Line Format --default-auth=plugin--default-auth=plugin类型Type 字符串String 关于使用哪种客户端身份验证插件的提示。请参见 第 8.2.17 节,“可插拔身份验证”。A hint about which client-side authentication plugin to use. See Section 8.2.17, “Pluggable Authentication”.
--defaults-extra-file=file_name--defaults-extra-file=file_name命令行格式Command-Line Format --defaults-extra-file=file_name--defaults-extra-file=file_name类型Type 文件名File name 在全局选项文件之后读取此选项文件,但(在 Unix 系统上)在用户选项文件之前。如果该文件不存在或无法访问,将发生错误。如果
file_name不是绝对路径名,则相对于当前目录解释。Read this option file after the global option file but (on Unix) before the user option file. If the file does not exist or is otherwise inaccessible, an error occurs. Iffile_nameis not an absolute path name, it is interpreted relative to the current directory.有关此选项文件选项及其他选项文件选项的更多信息,请参见 第 6.2.2.3 节,“影响选项文件处理的命令行选项”。For additional information about this and other option-file options, see Section 6.2.2.3, “Command-Line Options that Affect Option-File Handling”.
--defaults-file=file_name--defaults-file=file_name命令行格式Command-Line Format --defaults-file=file_name--defaults-file=file_name类型Type 文件名File name 仅使用指定的选项文件。如果文件不存在或无法访问,将会发生错误。如果
file_name不是绝对路径名,则将其相对于当前目录解释。Use only the given option file. If the file does not exist or is otherwise inaccessible, an error occurs. Iffile_nameis not an absolute path name, it is interpreted relative to the current directory.例外:即使使用
--defaults-file,客户端程序仍会读取.mylogin.cnf。Exception: Even with--defaults-file, client programs read.mylogin.cnf.有关此选项文件选项及其他选项文件选项的更多信息,请参见 第 6.2.2.3 节,“影响选项文件处理的命令行选项”。For additional information about this and other option-file options, see Section 6.2.2.3, “Command-Line Options that Affect Option-File Handling”.
命令行格式Command-Line Format --defaults-group-suffix=str--defaults-group-suffix=str类型Type 字符串String 不仅读取常规的选项组,还读取带有常规名称并加上
str后缀的组。例如,mysqlslap 通常读取[client]和[mysqlslap]组。如果此选项被指定为--defaults-group-suffix=_other,mysqlslap 还会读取[client_other]和[mysqlslap_other]组。Read not only the usual option groups, but also groups with the usual names and a suffix ofstr. For example, mysqlslap normally reads the[client]and[mysqlslap]groups. If this option is given as--defaults-group-suffix=_other, mysqlslap also reads the[client_other]and[mysqlslap_other]groups.有关此选项文件选项及其他选项文件选项的更多信息,请参见 第 6.2.2.3 节,“影响选项文件处理的命令行选项”。For additional information about this and other option-file options, see Section 6.2.2.3, “Command-Line Options that Affect Option-File Handling”.
--delimiter=,str-Fstr命令行格式Command-Line Format --delimiter=str类型Type 字符串String 在文件中提供或使用命令选项时,在 SQL 语句中使用的分隔符。The delimiter to use in SQL statements supplied in files or using command options.
命令行格式Command-Line Format --detach=#类型Type 数字Numeric 默认值Default Value 0在每执行
N条语句后分离(关闭并重新打开)每个连接。默认值为 0(不分离连接)。Detach (close and reopen) each connection after eachNstatements. The default is 0 (connections are not detached).命令行格式Command-Line Format --enable-cleartext-plugin类型Type 布尔Boolean 默认值Default Value FALSE启用
mysql_clear_password明文身份验证插件。(参见 第 8.4.1.4 节,“客户端明文可插拔身份验证”。)Enable themysql_clear_passwordcleartext authentication plugin. (See Section 8.4.1.4, “Client-Side Cleartext Pluggable Authentication”.)--engine=,engine_name-eengine_name命令行格式Command-Line Format --engine=engine_name类型Type 字符串String 用于创建表的存储引擎。The storage engine to use for creating tables.
命令行格式Command-Line Format --get-server-public-key--get-server-public-key类型Type 布尔Boolean 向服务器请求其用于基于密钥对的密码交换的 RSA 公钥。此选项适用于使用
caching_sha2_password认证插件进行身份验证的账户连接服务器的客户端。对于此类账户的连接,除非请求,否则服务器不会将公钥发送给客户端。对于未通过该插件进行身份验证的账户,此选项将被忽略。如果不需要基于 RSA 的密码交换,比如客户端通过安全连接连接到服务器的情况,该选项也会被忽略。Request from the server the RSA public key that it uses for key pair-based password exchange. This option applies to clients that connect to the server using an account that authenticates with thecaching_sha2_passwordauthentication plugin. For connections by such accounts, the server does not send the public key to the client unless requested. The option is ignored for accounts that do not authenticate with that plugin. It is also ignored if RSA-based password exchange is not needed, as is the case when the client connects to the server using a secure connection.如果提供了
--server-public-key-path=并指定了有效的公钥文件,它将优先于file_name--get-server-public-key。If--server-public-key-path=is given and specifies a valid public key file, it takes precedence overfile_name--get-server-public-key.有关
caching_sha2_password插件的信息,请参见 第 8.4.1.2 节,“缓存 SHA-2 可插拔认证”。For information about thecaching_sha2_passwordplugin, see Section 8.4.1.2, “Caching SHA-2 Pluggable Authentication”.--host=host_name,-h host_name--host=,host_name-hhost_name命令行格式Command-Line Format --host=host_name--host=host_name类型Type 字符串String 默认值Default Value localhostlocalhost连接到给定主机上的 MySQL 服务器。Connect to the MySQL server on the given host.
--iterations=,N-iN命令行格式Command-Line Format --iterations=#类型Type 数字Numeric 运行测试的次数。The number of times to run the tests.
--login-path=name--login-path=name命令行格式Command-Line Format --login-path=name--login-path=name类型Type 字符串String 从名为登录路径的
.mylogin.cnf登录路径文件中读取选项。“登录路径” 是一个选项组,包含指定要连接哪个 MySQL 服务器以及以哪个帐户进行身份验证的选项。要创建或修改登录路径文件,请使用 mysql_config_editor 工具。参见 第 6.6.7 节,“mysql_config_editor — MySQL 配置工具”。Read options from the named login path in the.mylogin.cnflogin path file. A “login path” is an option group containing options that specify which MySQL server to connect to and which account to authenticate as. To create or modify a login path file, use the mysql_config_editor utility. See Section 6.6.7, “mysql_config_editor — MySQL Configuration Utility”.有关此选项文件选项及其他选项文件选项的更多信息,请参见 第 6.2.2.3 节,“影响选项文件处理的命令行选项”。For additional information about this and other option-file options, see Section 6.2.2.3, “Command-Line Options that Affect Option-File Handling”.
命令行格式Command-Line Format --no-login-paths跳过从登录路径文件读取选项。Skips reading options from the login path file.
有关信息,请参见
--login-path。See--login-pathfor related information.有关此选项文件选项及其他选项文件选项的更多信息,请参见 第 6.2.2.3 节,“影响选项文件处理的命令行选项”。For additional information about this and other option-file options, see Section 6.2.2.3, “Command-Line Options that Affect Option-File Handling”.
命令行格式Command-Line Format --no-drop类型Type 布尔Boolean 默认值Default Value FALSE防止 mysqlslap 在测试运行期间删除它创建的任何模式。Prevent mysqlslap from dropping any schema it creates during the test run.
命令行格式Command-Line Format --no-defaults--no-defaults不要读取任何选项文件。如果程序启动因从选项文件读取未知选项而失败,可以使用
--no-defaults来防止读取这些选项。Do not read any option files. If program startup fails due to reading unknown options from an option file,--no-defaultscan be used to prevent them from being read.例外情况是,如果存在,
.mylogin.cnf文件在所有情况下都会被读取。这允许以比在命令行上更安全的方式指定密码,即使使用了--no-defaults。要创建.mylogin.cnf,请使用 mysql_config_editor 工具。请参见 第 6.6.7 节,“mysql_config_editor — MySQL 配置工具”。The exception is that the.mylogin.cnffile is read in all cases, if it exists. This permits passwords to be specified in a safer way than on the command line even when--no-defaultsis used. To create.mylogin.cnf, use the mysql_config_editor utility. See Section 6.6.7, “mysql_config_editor — MySQL Configuration Utility”.有关此选项文件选项及其他选项文件选项的更多信息,请参见 第 6.2.2.3 节,“影响选项文件处理的命令行选项”。For additional information about this and other option-file options, see Section 6.2.2.3, “Command-Line Options that Affect Option-File Handling”.
--number-char-cols=,N-xN命令行格式Command-Line Format --number-char-cols=#类型Type 数字Numeric 如果指定了
--auto-generate-sql,使用的VARCHAR列的数量。The number ofVARCHARcolumns to use if--auto-generate-sqlis specified.--number-int-cols=,N-yN命令行格式Command-Line Format --number-int-cols=#类型Type 数字Numeric 如果指定了
--auto-generate-sql,则使用的INT列的数量。The number ofINTcolumns to use if--auto-generate-sqlis specified.命令行格式Command-Line Format --number-of-queries=#类型Type 数字Numeric 将每个客户端的查询限制为大约如此多的次数。查询计数考虑了语句分隔符。例如,如果你如下调用 mysqlslap,
;分隔符会被识别,因此查询字符串的每个实例计为两个查询。因此,插入的是 5 行(而不是 10 行)。Limit each client to approximately this many queries. Query counting takes into account the statement delimiter. For example, if you invoke mysqlslap as follows, the;delimiter is recognized so that each instance of the query string counts as two queries. As a result, 5 rows (not 10) are inserted.mysqlslap --delimiter=";" --number-of-queries=10 --query="use test;insert into t values(null)"命令行格式Command-Line Format --only-print类型Type 布尔Boolean 默认值Default Value FALSE不连接到数据库。mysqlslap 仅打印它本应执行的操作。Do not connect to databases. mysqlslap only prints what it would have done.
--password[=,password]-p[password]命令行格式Command-Line Format --password[=password]--password[=password]类型Type 字符串String 用于连接服务器的 MySQL 账户密码。密码值是可选的。如果未提供,mysqlslap 将提示输入密码。如果提供,
--password=或-p与随后的密码之间 不能有空格。如果未指定密码选项,默认是不发送密码。The password of the MySQL account used for connecting to the server. The password value is optional. If not given, mysqlslap prompts for one. If given, there must be no space between--password=or-pand the password following it. If no password option is specified, the default is to send no password.在命令行中指定密码应被视为不安全。为了避免在命令行中输入密码,请使用选项文件。请参阅 第 8.1.2.1 节,“终端用户密码安全指南”。Specifying a password on the command line should be considered insecure. To avoid giving the password on the command line, use an option file. See Section 8.1.2.1, “End-User Guidelines for Password Security”.
要明确指定没有密码,并且 mysqlslap 不应提示输入密码,请使用
--skip-password选项。To explicitly specify that there is no password and that mysqlslap should not prompt for one, use the--skip-passwordoption.用于连接服务器的 MySQL 账户的多因素身份验证因素 1 的密码。密码值是可选的。如果未提供,mysqlslap 会提示输入密码。如果提供,
--password1=与紧随其后的密码之间 不能有空格。如果未指定密码选项,默认是不发送密码。The password for multifactor authentication factor 1 of the MySQL account used for connecting to the server. The password value is optional. If not given, mysqlslap prompts for one. If given, there must be no space between--password1=and the password following it. If no password option is specified, the default is to send no password.在命令行中指定密码应被视为不安全。为了避免在命令行中输入密码,请使用选项文件。请参阅 第 8.1.2.1 节,“终端用户密码安全指南”。Specifying a password on the command line should be considered insecure. To avoid giving the password on the command line, use an option file. See Section 8.1.2.1, “End-User Guidelines for Password Security”.
要明确指定没有密码,并且 mysqlslap 不应提示输入密码,请使用
--skip-password1选项。To explicitly specify that there is no password and that mysqlslap should not prompt for one, use the--skip-password1option.--password1和--password是同义的,--skip-password1和--skip-password也是同义的。--password1and--passwordare synonymous, as are--skip-password1and--skip-password.用于连接服务器的 MySQL 帐户的多因素认证第二个因素的密码。此选项的语义与
--password1的语义类似;详细信息请参阅该选项的说明。The password for multifactor authentication factor 2 of the MySQL account used for connecting to the server. The semantics of this option are similar to the semantics for--password1; see the description of that option for details.用于连接到服务器的 MySQL 帐户的多因素认证第 3 因子的密码。此选项的语义与
--password1的语义类似;详情请参见该选项的描述。The password for multifactor authentication factor 3 of the MySQL account used for connecting to the server. The semantics of this option are similar to the semantics for--password1; see the description of that option for details.--pipe,-W命令行格式Command-Line Format --pipe类型Type 字符串String 在 Windows 上,通过命名管道连接到服务器。此选项仅在服务器启动时已启用
named_pipe系统变量以支持命名管道连接的情况下适用。此外,进行连接的用户必须是由named_pipe_full_access_group系统变量指定的 Windows 组的成员。On Windows, connect to the server using a named pipe. This option applies only if the server was started with thenamed_pipesystem variable enabled to support named-pipe connections. In addition, the user making the connection must be a member of the Windows group specified by thenamed_pipe_full_access_groupsystem variable.--plugin-dir=dir_name--plugin-dir=dir_name命令行格式Command-Line Format --plugin-dir=dir_name--plugin-dir=dir_name类型Type 目录名称Directory name 查找插件的目录。如果使用
--default-auth选项来指定身份验证插件,但 mysqlslap 未找到该插件,请指定此选项。参见 第 8.2.17 节,“可插拔身份验证”。The directory in which to look for plugins. Specify this option if the--default-authoption is used to specify an authentication plugin but mysqlslap does not find it. See Section 8.2.17, “Pluggable Authentication”.--port=port_num,-P port_num--port=,port_num-Pport_num命令行格式Command-Line Format --port=port_num--port=port_num类型Type 数字Numeric 默认值Default Value 3306对于 TCP/IP 连接,要使用的端口号。For TCP/IP connections, the port number to use.
--post-query=value--post-query=value命令行格式Command-Line Format --post-query=value--post-query=value类型Type 字符串String 包含在测试完成后要执行的语句的文件或字符串。此执行不计入时间统计。The file or string containing the statement to execute after the tests have completed. This execution is not counted for timing purposes.
--post-system=str--post-system=str命令行格式Command-Line Format --post-system=str--post-system=str类型Type 字符串String 在测试完成后使用
system()执行的字符串。此执行不会计入时间统计。The string to execute usingsystem()after the tests have completed. This execution is not counted for timing purposes.--pre-query=value--pre-query=value命令行格式Command-Line Format --pre-query=value--pre-query=value类型Type 字符串String 包含在运行测试之前要执行的语句的文件或字符串。此执行不计入时间统计。The file or string containing the statement to execute before running the tests. This execution is not counted for timing purposes.
--pre-system=str--pre-system=str命令行格式Command-Line Format --pre-system=str--pre-system=str类型Type 字符串String 在运行测试之前使用
system()执行的字符串。此执行不计入时间统计。The string to execute usingsystem()before running the tests. This execution is not counted for timing purposes.命令行格式Command-Line Format --print-defaults打印程序名称以及它从选项文件中获取的所有选项。Print the program name and all options that it gets from option files.
有关此选项文件选项及其他选项文件选项的更多信息,请参见 第 6.2.2.3 节,“影响选项文件处理的命令行选项”。For additional information about this and other option-file options, see Section 6.2.2.3, “Command-Line Options that Affect Option-File Handling”.
--protocol={TCP|SOCKET|PIPE|MEMORY}命令行格式Command-Line Format --protocol=type--protocol=type类型Type 字符串String 默认值Default Value [see text][see text]有效值Valid Values TCPSOCKETSOCKETPIPEPIPEMEMORYMEMORY用于连接服务器的传输协议。当其他连接参数通常导致使用的协议不是您想要的协议时,这很有用。有关允许值的详细信息,请参阅第 6.2.7 节,“连接传输协议”。The transport protocol to use for connecting to the server. It is useful when the other connection parameters normally result in use of a protocol other than the one you want. For details on the permissible values, see Section 6.2.7, “Connection Transport Protocols”.
--query=value,-q value--query=,value-qvalue命令行格式Command-Line Format --query=value--query=value类型Type 字符串String 用于检索数据的
SELECT语句的文件或字符串。The file or string containing theSELECTstatement to use for retrieving data.--server-public-key-path=file_name--server-public-key-path=file_name命令行格式Command-Line Format --server-public-key-path=file_name--server-public-key-path=file_name类型Type 文件名File name 包含服务器所需的 RSA 密钥对密码交换的客户端副本公钥的 PEM 格式文件的路径名。此选项适用于使用
sha256_password(已弃用)或caching_sha2_password身份验证插件进行身份验证的客户端。对于不使用这些插件之一进行身份验证的帐户,将忽略此选项。如果未使用基于 RSA 的密码交换(例如客户端使用安全连接连接到服务器的情况),此选项也将被忽略。The path name to a file in PEM format containing a client-side copy of the public key required by the server for RSA key pair-based password exchange. This option applies to clients that authenticate with thesha256_password(deprecated) orcaching_sha2_passwordauthentication plugin. This option is ignored for accounts that do not authenticate with one of those plugins. It is also ignored if RSA-based password exchange is not used, as is the case when the client connects to the server using a secure connection.如果提供了
--server-public-key-path=并指定了有效的公钥文件,它将优先于file_name--get-server-public-key。If--server-public-key-path=is given and specifies a valid public key file, it takes precedence overfile_name--get-server-public-key.对于
sha256_password(已弃用),此选项仅在 MySQL 使用 OpenSSL 构建时才适用。Forsha256_password(deprecated), this option applies only if MySQL was built using OpenSSL.有关
sha256_password和caching_sha2_password插件的信息,请参见 第 8.4.1.3 节,“SHA-256 可插拔认证” 和 第 8.4.1.2 节,“缓存 SHA-2 可插拔认证”。For information about thesha256_passwordandcaching_sha2_passwordplugins, see Section 8.4.1.3, “SHA-256 Pluggable Authentication”, and Section 8.4.1.2, “Caching SHA-2 Pluggable Authentication”.--shared-memory-base-name=name命令行格式Command-Line Format --shared-memory-base-name=name--shared-memory-base-name=name特定平台Platform Specific 窗口Windows 在 Windows 上,通过共享内存连接到本地服务器时使用的共享内存名称。默认值是
MYSQL。共享内存名称区分大小写。On Windows, the shared-memory name to use for connections made using shared memory to a local server. The default value isMYSQL. The shared-memory name is case-sensitive.此选项仅在服务器启用了
shared_memory系统变量以支持共享内存连接时适用。This option applies only if the server was started with theshared_memorysystem variable enabled to support shared-memory connections.--silent,-s命令行格式Command-Line Format --silent静音模式。无输出。Silent mode. No output.
--socket=path,-S path--socket=,path-Spath命令行格式Command-Line Format --socket={file_name|pipe_name}--socket={file_name|pipe_name}类型Type 字符串String 用于连接
localhost时,使用的 Unix 套接字文件,或者在 Windows 上使用的命名管道的名称。For connections tolocalhost, the Unix socket file to use, or, on Windows, the name of the named pipe to use.在 Windows 上,此选项仅在服务器启用支持命名管道连接的
named_pipe系统变量启动时才适用。此外,进行连接的用户必须是由named_pipe_full_access_group系统变量指定的 Windows 组的成员。On Windows, this option applies only if the server was started with thenamed_pipesystem variable enabled to support named-pipe connections. In addition, the user making the connection must be a member of the Windows group specified by thenamed_pipe_full_access_groupsystem variable.--sql-mode=mode--sql-mode=mode命令行格式Command-Line Format --sql-mode=mode--sql-mode=mode类型Type 字符串String 设置客户端会话的 SQL 模式。Set the SQL mode for the client session.
以
--ssl开头的选项指定是否使用加密连接到服务器,并指示在哪里可以找到 SSL 密钥和证书。请参阅 加密连接的命令选项。Options that begin with--sslspecify whether to connect to the server using encryption and indicate where to find SSL keys and certificates. See Command Options for Encrypted Connections.--ssl-fips-mode={OFF|ON|STRICT}命令行格式Command-Line Format --ssl-fips-mode={OFF|ON|STRICT}--ssl-fips-mode={OFF|ON|STRICT}已弃用Deprecated 是Yes 类型Type 枚举Enumeration 默认值Default Value OFFOFF有效值Valid Values OFFOFFONONSTRICTSTRICT控制是否在客户端启用 FIPS 模式。
--ssl-fips-mode选项不同于其他--ssl-选项,它不是用于建立加密连接,而是影响允许使用哪些加密操作。请参阅 第 8.8 节,“FIPS 支持”。Controls whether to enable FIPS mode on the client side. Thexxx--ssl-fips-modeoption differs from other--ssl-options in that it is not used to establish encrypted connections, but rather to affect which cryptographic operations to permit. See Section 8.8, “FIPS Support”.xxx允许使用这些
--ssl-fips-mode值:These--ssl-fips-modevalues are permitted:OFF:禁用 FIPS 模式。OFF: Disable FIPS mode.ON:启用 FIPS 模式。ON: Enable FIPS mode.STRICT:启用“严格” FIPS 模式。STRICT: Enable “strict” FIPS mode.
Note如果 OpenSSL FIPS 对象模块不可用,
--ssl-fips-mode唯一允许的值是OFF。在这种情况下,将--ssl-fips-mode设置为ON或STRICT会导致客户端在启动时发出警告,并以非 FIPS 模式运行。If the OpenSSL FIPS Object Module is not available, the only permitted value for--ssl-fips-modeisOFF. In this case, setting--ssl-fips-modetoONorSTRICTcauses the client to produce a warning at startup and to operate in non-FIPS mode.此选项已弃用。预计将在未来的 MySQL 版本中移除。This option is deprecated. Expect it to be removed in a future version of MySQL.
--tls-ciphersuites=ciphersuite_list--tls-ciphersuites=ciphersuite_list命令行格式Command-Line Format --tls-ciphersuites=ciphersuite_list--tls-ciphersuites=ciphersuite_list类型Type 字符串String 用于 TLSv1.3 加密连接的允许密码套件。该值是一个或多个用冒号分隔的密码套件名称的列表。此选项可指定的密码套件取决于用于编译 MySQL 的 SSL 库。有关详细信息,请参见 第 8.3.2 节,“加密连接的 TLS 协议和密码”。The permissible ciphersuites for encrypted connections that use TLSv1.3. The value is a list of one or more colon-separated ciphersuite names. The ciphersuites that can be named for this option depend on the SSL library used to compile MySQL. For details, see Section 8.3.2, “Encrypted Connection TLS Protocols and Ciphers”.
--tls-sni-servername=server_name--tls-sni-servername=server_name命令行格式Command-Line Format --tls-sni-servername=server_name--tls-sni-servername=server_name类型Type 字符串String 如果指定了名称,该名称将通过
mysql_options()的MYSQL_OPT_TLS_SNI_SERVERNAME选项传递给libmysqlclientC API 库。服务器名称不区分大小写。要显示客户端为当前会话指定的服务器名称(如果有),请检查Tls_sni_server_name状态变量。When specified, the name is passed to thelibmysqlclientC API library using theMYSQL_OPT_TLS_SNI_SERVERNAMEoption ofmysql_options(). The server name is not case-sensitive. To show which server name the client specified for the current session, if any, check theTls_sni_server_namestatus variable.服务器名称指示(SNI)是 TLS 协议的一个扩展(必须使用支持 TLS 扩展的 OpenSSL 编译此选项才能生效)。MySQL 对 SNI 的实现仅代表客户端。Server Name Indication (SNI) is an extension to the TLS protocol (OpenSSL must be compiled using TLS extensions for this option to function). The MySQL implementation of SNI represents the client-side only.
--tls-version=protocol_list--tls-version=protocol_list命令行格式Command-Line Format --tls-version=protocol_list--tls-version=protocol_list类型Type 字符串String 默认值Default Value TLSv1,TLSv1.1,TLSv1.2,TLSv1.3(OpenSSL 1.1.1 或更高版本)TLSv1,TLSv1.1,TLSv1.2,TLSv1.3(OpenSSL 1.1.1 or higher)TLSv1,TLSv1.1,TLSv1.2(否则)TLSv1,TLSv1.1,TLSv1.2(otherwise)用于加密连接的允许 TLS 协议。值是一个或多个以逗号分隔的协议名称列表。此选项可指定的协议取决于用于编译 MySQL 的 SSL 库。详情请参见 第 8.3.2 节,“加密连接 TLS 协议和密码”。The permissible TLS protocols for encrypted connections. The value is a list of one or more comma-separated protocol names. The protocols that can be named for this option depend on the SSL library used to compile MySQL. For details, see Section 8.3.2, “Encrypted Connection TLS Protocols and Ciphers”.
--user=user_name,-u user_name--user=,user_name-uuser_name命令行格式Command-Line Format --user=user_name,--user=user_name,类型Type 字符串String 用于连接服务器的 MySQL 帐户用户名。The user name of the MySQL account to use for connecting to the server.
--verbose,-v命令行格式Command-Line Format --verbose--verbose详细模式。打印有关程序执行内容的更多信息。此选项可以多次使用以增加信息量。Verbose mode. Print more information about what the program does. This option can be used multiple times to increase the amount of information.
--version,-V命令行格式Command-Line Format --version显示版本信息并退出。Display version information and exit.
--zstd-compression-level=level--zstd-compression-level=level命令行格式Command-Line Format --zstd-compression-level=#类型Type 整数Integer 用于与服务器连接时使用
zstd压缩算法的压缩级别。允许的级别从 1 到 22,数值越大表示压缩级别越高。默认的zstd压缩级别为 3。对于不使用zstd压缩的连接,压缩级别设置没有效果。The compression level to use for connections to the server that use thezstdcompression algorithm. The permitted levels are from 1 to 22, with larger values indicating increasing levels of compression. The defaultzstdcompression level is 3. The compression level setting has no effect on connections that do not usezstdcompression.更多信息,请参阅 第 6.2.8 节,“连接压缩控制”。For more information, see Section 6.2.8, “Connection Compression Control”.