mysqlimport 客户端提供了一个命令行接口,用于执行 LOAD DATA SQL 语句。mysqlimport 的大多数选项都直接对应于 LOAD
DATA 语法的各个子句。参见 第 15.2.9 节,“LOAD DATA 语句”。The mysqlimport client provides a
command-line interface to the LOAD
DATA SQL statement. Most options to
mysqlimport correspond directly to clauses of
LOAD DATA syntax. See
Section 15.2.9, “LOAD DATA Statement”.
像这样调用 mysqlimport:Invoke mysqlimport like this:
mysqlimport [options]db_nametextfile1[textfile2...]
对于命令行上指定的每个文本文件,mysqlimport 会去掉文件名的任何扩展名,并使用结果来确定将文件内容导入到哪个表。例如,名为 patient.txt、patient.text 和 patient 的文件都将被导入到名为 patient 的表中。For each text file named on the command line,
mysqlimport strips any extension from the
file name and uses the result to determine the name of the table
into which to import the file's contents. For example, files
named patient.txt,
patient.text, and
patient all would be imported into a table
named patient.
mysqlimport 支持以下选项,这些选项可以在命令行中指定,也可以在选项文件的 [mysqlimport] 和 [client] 组中指定。有关 MySQL 程序使用的选项文件的信息,请参见 第 6.2.2.2 节,“使用选项文件”。mysqlimport supports the following options,
which can be specified on the command line or in the
[mysqlimport] 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.14 mysqlimport 选项Table 6.14 mysqlimport Options
| 选项名称Option Name | 说明Description |
|---|---|
| --绑定地址--bind-address | 使用指定的网络接口连接到 MySQL 服务器Use specified network interface to connect to MySQL Server |
| --字符集目录--character-sets-dir | 可以找到字符集的目录Directory where character sets can be found |
| --列--columns | 此选项将逗号分隔的列名列表作为其值This option takes a comma-separated list of column names as its value |
| --压缩--compress | 压缩客户端和服务器之间发送的所有信息Compress all information sent between client and server |
| --压缩算法--compression-algorithms | 允许用于连接服务器的压缩算法Permitted compression algorithms for connections to server |
| --调试--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 |
| --默认字符集--default-character-set | 指定默认字符集Specify default character set |
| --附加默认文件--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 |
| --删除--delete | 在导入文本文件之前请清空表格Empty the table before importing the text file |
| --启用明文插件--enable-cleartext-plugin | 启用明文身份验证插件Enable cleartext authentication plugin |
| --字段由…括起--fields-enclosed-by | 此选项与 LOAD DATA 的相应条款具有相同的含义This option has the same meaning as the corresponding clause for LOAD DATA |
| --字段由…转义--fields-escaped-by | 此选项与 LOAD DATA 的相应条款具有相同的含义This option has the same meaning as the corresponding clause for LOAD DATA |
| --字段可选地由…括起--fields-optionally-enclosed-by | 此选项与 LOAD DATA 的相应条款具有相同的含义This option has the same meaning as the corresponding clause for LOAD DATA |
| --fields-terminated-by(字段分隔符)--fields-terminated-by | 此选项与 LOAD DATA 的相应条款具有相同的含义This option has the same meaning as the corresponding clause for LOAD DATA |
| --force(强制)--force | 即使发生 SQL 错误也继续Continue even if an SQL error occurs |
| --get-server-public-key(获取服务器公钥)--get-server-public-key | 从服务器请求 RSA 公钥Request RSA public key from server |
| --help(帮助)--help | 显示帮助信息并退出Display help message and exit |
| --host(主机)--host | MySQL 服务器所在的主机Host on which MySQL server is located |
| --ignore(忽略)--ignore | 查看 --replace 选项的说明See the description for the --replace option |
| --ignore-lines(忽略行)--ignore-lines | 忽略数据文件的前 N 行Ignore the first N lines of the data file |
| --lines-terminated-by(行终止符)--lines-terminated-by | 此选项与 LOAD DATA 的相应条款具有相同的含义This option has the same meaning as the corresponding clause for LOAD DATA |
| --local(本地)--local | 从客户端主机本地读取输入文件Read input files locally from the client host |
| --lock-tables(锁表)--lock-tables | 在处理任何文本文件之前锁定所有表格以进行写入Lock all tables for writing before processing any text files |
| --登录路径--login-path | 从 .mylogin.cnf 读取登录路径选项Read login path options from .mylogin.cnf |
| --低优先级--low-priority | 在加载表时使用 LOW_PRIORITYUse LOW_PRIORITY when loading the table |
| --no-defaults(不使用默认设置)--no-defaults | 不读取任何选项文件Read no option files |
| --no-login-paths(不使用登录路径)--no-login-paths | 不要从登录路径文件中读取登录路径Do not read login paths from the login path file |
| --password(密码)--password | 连接服务器时使用的密码Password to use when connecting to server |
| --password1(密码 1)--password1 | 首次多因素身份验证密码,用于连接服务器First multifactor authentication password to use when connecting to server |
| --password2(密码 2)--password2 | 连接服务器时使用的第二个多因素认证密码Second multifactor authentication password to use when connecting to server |
| --password3(密码 3)--password3 | 连接服务器时使用的第三个多因素认证密码Third multifactor authentication password to use when connecting to server |
| --pipe(管道)--pipe | 使用命名管道连接到服务器(仅限 Windows)Connect to server using named pipe (Windows only) |
| --plugin-dir(插件目录)--plugin-dir | 插件安装的目录Directory where plugins are installed |
| --port(端口)--port | 连接的 TCP/IP 端口号TCP/IP port number for connection |
| --print-defaults(打印默认设置)--print-defaults | 打印默认选项Print default options |
| --协议--protocol | 要使用的传输协议Transport protocol to use |
| --替换--replace | --replace 和 --ignore 选项控制对在唯一键值上与现有行重复的输入行的处理The --replace and --ignore options control handling of input rows that duplicate existing rows on unique key values |
| --服务器公钥路径--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 | 仅在发生错误时输出Produce output only when errors occur |
| --套接字--socket | 要使用的 Unix 套接字文件或 Windows 命名管道Unix socket file or Windows named pipe to use |
| --ssl-ca | 包含受信任的 SSL 证书颁发机构列表的文件File that contains list of trusted SSL Certificate Authorities |
| --SSL-路径--ssl-capath | 包含受信任的 SSL 证书颁发机构证书文件的目录Directory that contains trusted SSL Certificate Authority certificate files |
| --SSL 证书--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-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 |
| --使用线程--use-threads | 用于并行文件加载的线程数Number of threads for parallel file-loading |
| --用户--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.
--bind-address=ip_address--bind-address=ip_address命令行格式Command-Line Format --bind-address=ip_address--bind-address=ip_address在具有多个网络接口的计算机上,使用此选项选择用于连接到 MySQL 服务器的接口。On a computer having multiple network interfaces, use this option to select which interface to use for connecting to the MySQL server.
--character-sets-dir=dir_name--character-sets-dir=dir_name命令行格式Command-Line Format --character-sets-dir=path--character-sets-dir=path类型Type 字符串String 默认值Default Value [none][none]安装字符集的目录。请参见第 12.15 节,“字符集配置”。The directory where character sets are installed. See Section 12.15, “Character Set Configuration”.
--columns=column_list,-c column_list--columns=,column_list-ccolumn_list命令行格式Command-Line Format --columns=column_list--columns=column_list此选项将以逗号分隔的列名称列表作为其值。列名称的顺序表示如何将数据文件列与表列匹配。This option takes a list of comma-separated column names as its value. The order of the column names indicates how to match data file columns with table columns.
--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”.
--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写入调试日志。典型的
debug_options字符串是d:t:o,。默认值是file_named:t:o。Write a debugging log. A typicaldebug_optionsstring isd:t:o,. The default isfile_named:t:o.此选项仅在 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.命令行格式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-character-set=charset_name--default-character-set=charset_name命令行格式Command-Line Format --default-character-set=charset_name--default-character-set=charset_name类型Type 字符串String 使用
charset_name作为默认字符集。请参见 第 12.15 节,“字符集配置”。Usecharset_nameas the default character set. See Section 12.15, “Character Set Configuration”.--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”.
--defaults-group-suffix=str--defaults-group-suffix=str命令行格式Command-Line Format --defaults-group-suffix=str--defaults-group-suffix=str类型Type 字符串String 不仅要读取常规的选项组,还要读取带有常规名称并附有
str后缀的组。例如,mysqlimport 通常读取[client]和[mysqlimport]组。如果该选项被指定为--defaults-group-suffix=_other,mysqlimport 还会读取[client_other]和[mysqlimport_other]组。Read not only the usual option groups, but also groups with the usual names and a suffix ofstr. For example, mysqlimport normally reads the[client]and[mysqlimport]groups. If this option is given as--defaults-group-suffix=_other, mysqlimport also reads the[client_other]and[mysqlimport_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”.
--delete,-D命令行格式Command-Line Format --delete在导入文本文件之前请清空表格。Empty the table before importing the text file.
命令行格式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”.)--fields-terminated-by=...,--fields-enclosed-by=...,--fields-optionally-enclosed-by=...,--fields-escaped-by=...命令行格式Command-Line Format --fields-terminated-by=string--fields-terminated-by=string类型Type 字符串String 命令行格式Command-Line Format --fields-enclosed-by=string--fields-enclosed-by=string类型Type 字符串String 命令行格式Command-Line Format --fields-optionally-enclosed-by=string--fields-optionally-enclosed-by=string类型Type 字符串String 命令行格式Command-Line Format --fields-escaped-by类型Type 字符串String 这些选项的含义与
LOAD DATA的相应子句相同。请参见 第 15.2.9 节,“LOAD DATA 语句”。These options have the same meaning as the corresponding clauses forLOAD DATA. See Section 15.2.9, “LOAD DATA Statement”.--force,-f命令行格式Command-Line Format --force忽略错误。例如,如果文本文件的表不存在,则继续处理剩余的文件。如果没有
--force,mysqlimport 会在表不存在时退出。Ignore errors. For example, if a table for a text file does not exist, continue processing any remaining files. Without--force, mysqlimport exits if a table does not exist.命令行格式Command-Line Format --get-server-public-key--get-server-public-key类型Type 布尔Boolean 向服务器请求用于基于 RSA 密钥对的密码交换所需的公钥。此选项适用于使用
caching_sha2_password身份验证插件进行身份验证的客户端。对于该插件,服务器不会发送公钥,除非被请求。对于未使用该插件进行身份验证的账户,此选项将被忽略。当未使用基于 RSA 的密码交换时(例如客户端使用安全连接连接服务器时),此选项也将被忽略。Request from the server the public key required for RSA key pair-based password exchange. This option applies to clients that authenticate with thecaching_sha2_passwordauthentication plugin. For that plugin, the server does not send the public key unless requested. This option is ignored for accounts that do not authenticate with that plugin. 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.有关
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-hhost_name命令行格式Command-Line Format --host=host_name--host=host_name类型Type 字符串String 默认值Default Value localhostlocalhost将数据导入到指定主机上的 MySQL 服务器。默认主机为
localhost。Import data to the MySQL server on the given host. The default host islocalhost.--ignore,-i命令行格式Command-Line Format --ignore参见
--replace选项的描述。See the description for the--replaceoption.命令行格式Command-Line Format --ignore-lines=#类型Type 数字Numeric 忽略数据文件的前
N行。Ignore the firstNlines of the data file.命令行格式Command-Line Format --lines-terminated-by=string--lines-terminated-by=string类型Type 字符串String 此选项与
LOAD DATA对应子句的含义相同。例如,要导入以回车/换行符结尾的 Windows 文件,请使用--lines-terminated-by="\r\n"。(根据命令解释器的转义规则,可能需要将反斜杠加倍。)请参阅 第 15.2.9 节,“LOAD DATA 语句”。This option has the same meaning as the corresponding clause forLOAD DATA. For example, to import Windows files that have lines terminated with carriage return/linefeed pairs, use--lines-terminated-by="\r\n". (You might have to double the backslashes, depending on the escaping conventions of your command interpreter.) See Section 15.2.9, “LOAD DATA Statement”.--local,-L命令行格式Command-Line Format --local类型Type 布尔Boolean 默认值Default Value FALSE默认情况下,文件由服务器在服务器主机上读取。使用此选项,mysqlimport 在客户端主机上本地读取输入文件。By default, files are read by the server on the server host. With this option, mysqlimport reads input files locally on the client host.
在 mysqlimport 中成功使用
LOCAL加载操作还需要服务器允许本地加载;请参见 第 8.1.6 节,“LOAD DATA LOCAL 的安全性考虑”Successful use ofLOCALload operations within mysqlimport also requires that the server permits local loading; see Section 8.1.6, “Security Considerations for LOAD DATA LOCAL”--lock-tables,-l命令行格式Command-Line Format --lock-tables在处理任何文本文件之前锁定所有表以进行写操作。这确保了服务器上所有表的同步。Lock all tables for writing before processing any text files. This ensures that all tables are synchronized on the server.
--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 --low-priority--low-priority在加载表时使用
LOW_PRIORITY。这仅影响仅使用表级锁定的存储引擎(例如MyISAM、MEMORY和MERGE)。UseLOW_PRIORITYwhen loading the table. This affects only storage engines that use only table-level locking (such asMyISAM,MEMORY, andMERGE).命令行格式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”.
--password[=password],-p[password]--password[=,password]-p[password]命令行格式Command-Line Format --password[=password]--password[=password]类型Type 字符串String 用于连接服务器的 MySQL 帐户的密码。密码值是可选的。如果未提供,mysqlimport 会提示输入密码。如果提供了密码,
--password=或-p后面与密码之间不得有空格。如果未指定密码选项,默认不发送密码。The password of the MySQL account used for connecting to the server. The password value is optional. If not given, mysqlimport 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”.
要明确指定没有密码,并且 mysqlimport 不应提示输入密码,请使用
--skip-password选项。To explicitly specify that there is no password and that mysqlimport should not prompt for one, use the--skip-passwordoption.--password1[=pass_val]--password1[=pass_val]用于连接服务器的 MySQL 帐户多因素认证因素 1 的密码。密码值是可选的。如果未提供,mysqlimport 会提示输入密码。如果提供,则
--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, mysqlimport 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”.
要明确指定没有密码,并且 mysqlimport 不应提示输入密码,请使用
--skip-password1选项。To explicitly specify that there is no password and that mysqlimport should not prompt for one, use the--skip-password1option.--password1和--password是同义的,--skip-password1和--skip-password也是同义的。--password1and--passwordare synonymous, as are--skip-password1and--skip-password.--password2[=pass_val]--password2[=pass_val]用于连接服务器的 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.--password3[=pass_val]--password3[=pass_val]用于连接服务器的 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选项来指定认证插件,但 mysqlimport 未找到它,则请指定此选项。参见 第 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 mysqlimport 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.
命令行格式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”.
--replace,-r命令行格式Command-Line Format --replace--replace--replace和--ignore选项用于控制处理在唯一键值上与现有行重复的输入行。如果指定--replace,新行将替换具有相同唯一键值的现有行。如果指定--ignore,与现有行在唯一键值上重复的输入行将被跳过。如果没有指定任何选项,在发现重复键值时会发生错误,并且文本文件的其余部分将被忽略。The--replaceand--ignoreoptions control handling of input rows that duplicate existing rows on unique key values. If you specify--replace, new rows replace existing rows that have the same unique key value. If you specify--ignore, input rows that duplicate an existing row on a unique key value are skipped. If you do not specify either option, an error occurs when a duplicate key value is found, and the rest of the text file is ignored.--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--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. Produce output only when errors occur.
--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.以
--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}--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命令行格式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.
命令行格式Command-Line Format --use-threads=#类型Type 数字Numeric 使用
N个线程并行加载文件。Load files in parallel usingNthreads.--verbose,-v命令行格式Command-Line Format --verbose--verbose详细模式。打印有关程序执行内容的更多信息。Verbose mode. Print more information about what the program does.
--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”.
下面是一个示例会话,演示了如何使用 mysqlimport:Here is a sample session that demonstrates use of mysqlimport:
$>mysql -e 'CREATE TABLE imptest(id INT, n VARCHAR(30))' test$>eda 100 Max Sydow 101 Count Dracula . w imptest.txt 32 q $>od -c imptest.txt0000000 1 0 0 \t M a x S y d o w \n 1 0 0000020 1 \t C o u n t D r a c u l a \n 0000040 $>mysqlimport --local test imptest.txttest.imptest: Records: 2 Deleted: 0 Skipped: 0 Warnings: 0 $>mysql -e 'SELECT * FROM imptest' test+------+---------------+ | id | n | +------+---------------+ | 100 | Max Sydow | | 101 | Count Dracula | +------+---------------+