Skip to main content

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

ScenarioRecommendedNotes
Data migration in development and testing environmentsRecommendedSimple to operate, the tool is widely available
Schema backup and migrationRecommendedUse --no-data to export only DDL
Small-scale data exportRecommendedSeveral MB to hundreds of MB
Large-scale data export in production environmentsNot recommendedPerformance and stability are limited. Use EXPORT or OUTFILE instead

Prerequisites

  • Doris version >= 0.15
  • mysqldump is 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).

  1. Export the schema and data of a specified table

    mysqldump -h127.0.0.1 -P9030 -uroot --no-tablespaces \
    --databases test --tables table1
  2. 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
  3. Export all tables under multiple databases

    mysqldump -h127.0.0.1 -P9030 -uroot --no-tablespaces \
    --databases test1 test2
  4. 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

  1. The --no-tablespaces parameter is required: Doris does not support the MySQL tablespace concept. Without this parameter, the export will fail.
  2. Only suitable for development, testing, or small-scale scenarios: mysqldump is 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: