8.4 中文镜像

MySQL 8.4 参考手册 · 中文镜像

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

打开官方英文原文 ↗

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

MySQL 8.4 参考手册 / 9 备份与恢复 / 9.4 使用 mysqldump 进行备份 / 9.4.4 重新加载分隔文本格式备份
中文点击中文段落可显示 / 隐藏英文原文本页译文覆盖 100%

9.4.4 重新加载分隔文本格式备份9.4.4 Reloading Delimited-Text Format Backups

对于使用 mysqldump --tab 生成的备份,每个表在输出目录中由一个 .sql 文件表示,包含表的 CREATE TABLE 语句,以及一个 .txt 文件,包含表数据。要重新加载表,首先切换到输出目录。然后使用 mysql 处理 .sql 文件以创建空表,并处理 .txt 文件将数据加载到表中:For backups produced with mysqldump --tab, each table is represented in the output directory by an .sql file containing the CREATE TABLE statement for the table, and a .txt file containing the table data. To reload a table, first change location into the output directory. Then process the .sql file with mysql to create an empty table and process the .txt file to load the data into the table:

$> mysql db1 < t1.sql
$> mysqlimport db1 t1.txt

加载数据文件的一个替代方法是使用 mysqlimport,也可以在 mysql 客户端中使用 LOAD DATA 语句:An alternative to using mysqlimport to load the data file is to use the LOAD DATA statement from within the mysql client:

mysql> USE db1;
mysql> LOAD DATA INFILE 't1.txt' INTO TABLE t1;

如果你在最初导出表时使用了mysqldump的任何数据格式化选项,你必须在使用mysqlimport或LOAD DATA时使用相同的选项,以确保数据文件内容得到正确解释:If you used any data-formatting options with mysqldump when you initially dumped the table, you must use the same options with mysqlimport or LOAD DATA to ensure proper interpretation of the data file contents:

$> mysqlimport --fields-terminated-by=,
         --fields-enclosed-by='"' --lines-terminated-by=0x0d0a db1 t1.txt

或者:Or:

mysql> USE db1;
mysql> LOAD DATA INFILE 't1.txt' INTO TABLE t1
       FIELDS TERMINATED BY ',' FIELDS ENCLOSED BY '"'
       LINES TERMINATED BY '\r\n';