8.4 中文镜像

MySQL 8.4 参考手册 · 中文镜像

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

打开官方英文原文 ↗

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

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

9.4 使用 mysqldump 进行备份9.4 Using mysqldump for Backups

Tip

考虑使用 MySQL Shell 转储实用程序,它提供多线程并行转储、文件压缩和进度信息显示,以及 Oracle 云基础设施对象存储流和 MySQL HeatWave 兼容性检查和修改等云功能。使用 MySQL Shell 负载转储实用程序可以轻松地将转储导入到 MySQL 服务器实例或 MySQL HeatWave 数据库系统中。 MySQL Shell 的安装说明可以在此处找到。Consider using the MySQL Shell dump utilities, which provide parallel dumping with multiple threads, file compression, and progress information display, as well as cloud features such as Oracle Cloud Infrastructure Object Storage streaming, and MySQL HeatWave compatibility checks and modifications. Dumps can be easily imported into a MySQL Server instance or a MySQL HeatWave DB System using the MySQL Shell load dump utilities. Installation instructions for MySQL Shell can be found here.

本节介绍如何使用 mysqldump 生成转储文件,以及如何重新加载转储文件。转储文件可以以多种方式使用:This section describes how to use mysqldump to produce dump files, and how to reload dump files. A dump file can be used in several ways:

  • 作为备份,以在数据丢失的情况下启用数据恢复。As a backup to enable data recovery in case of data loss.

  • 作为设置副本的数据来源。As a source of data for setting up replicas.

  • 作为实验数据来源:As a source of data for experimentation:

    • 制作数据库的副本,以便在不更改原始数据的情况下使用。To make a copy of a database that you can use without changing the original data.

    • 测试潜在的升级不兼容性。To test potential upgrade incompatibilities.

mysqldump 会生成两种类型的输出,取决于是否给出了 --tab 选项:mysqldump produces two types of output, depending on whether the --tab option is given:

  • 没有 --tab 选项时,mysqldump 会将 SQL 语句写入标准输出。该输出包含用于创建导出对象(数据库、表、存储过程等)的 CREATE 语句,以及用于向表中加载数据的 INSERT 语句。输出可以保存到文件中,并使用 mysql 重新加载,以重新创建导出的对象。可以使用选项修改 SQL 语句的格式,并控制导出的对象。Without --tab, mysqldump writes SQL statements to the standard output. This output consists of CREATE statements to create dumped objects (databases, tables, stored routines, and so forth), and INSERT statements to load data into tables. The output can be saved in a file and reloaded later using mysql to recreate the dumped objects. Options are available to modify the format of the SQL statements, and to control which objects are dumped.

  • 使用 --tab 时,mysqldump 会为每个导出的表生成两个输出文件。服务器将其中一个文件写为制表符分隔的文本,每行对应表中的一行数据。该文件在输出目录中名为 tbl_name.txt。服务器还会将表的 CREATE TABLE 语句发送给 mysqldump,后者将其写为输出目录中的文件,文件名为 tbl_name.sql。With --tab, mysqldump produces two output files for each dumped table. The server writes one file as tab-delimited text, one line per table row. This file is named tbl_name.txt in the output directory. The server also sends a CREATE TABLE statement for the table to mysqldump, which writes it as a file named tbl_name.sql in the output directory.