MySQL Dump
mysqldump is the official logical export tool provided by MySQL. Starting from version 0.15, Apache Doris is compatible with mysqldump. You can use it to export table schemas (DDL) or data (DML), and then re-import them into Doris with the source command.
Applicable Scenarios
| Scenario | Recommended | Notes |
|---|---|---|
| Data migration in development and testing environments | Recommended | Simple to operate, the tool is widely available |
| Schema backup and migration | Recommended | Use --no-data to export only DDL |
| Small-scale data export | Recommended | Several MB to hundreds of MB |
| Large-scale data export in production environments | Not recommended | Performance and stability are limited. Use EXPORT or OUTFILE instead |
Prerequisites
- Doris version >= 0.15
mysqldumpis installed in the client environment- You have read permission on the target databases and tables (the default FE MySQL protocol port is
9030)
Usage Examples
Export Data or Schema
The following examples all connect to the FE at 127.0.0.1:9030 using the root account, and must include the --no-tablespaces parameter (see "Notes" below for the reason).
-
Export the schema and data of a specified table
mysqldump -h127.0.0.1 -P9030 -uroot --no-tablespaces \
--databases test --tables table1 -
Export only the schema of a specified table (without data)
mysqldump -h127.0.0.1 -P9030 -uroot --no-tablespaces \
--databases test --tables table1 --no-data -
Export all tables under multiple databases
mysqldump -h127.0.0.1 -P9030 -uroot --no-tablespaces \
--databases test1 test2 -
Export all databases and all tables
mysqldump -h127.0.0.1 -P9030 -uroot --no-tablespaces \
--all-databases
For more parameters, refer to the official MySQL mysqldump manual.
Import the Exported Result into Doris
The output of mysqldump can be redirected to a .sql file, and then imported via the source command in the Doris client:
# 1. Export to a file
mysqldump -h127.0.0.1 -P9030 -uroot --no-tablespaces \
--databases test --tables table1 > table1.sql
# 2. Log in to Doris and run source to import
mysql -h127.0.0.1 -P9030 -uroot
source table1.sql;
Notes
- The
--no-tablespacesparameter is required: Doris does not support the MySQL tablespace concept. Without this parameter, the export will fail. - Only suitable for development, testing, or small-scale scenarios:
mysqldumpis a single-threaded logical export tool. Its performance and stability are not ideal for large data volumes. Do not use it for large-scale data in production environments. For data export in production environments, use one of the following approaches:EXPORTstatement: asynchronously export to object storage or HDFSSELECT INTO OUTFILE: synchronously export query results to a file