All Products
Search
Document Center

ApsaraDB for SelectDB:Export data by using mysqldump

Last Updated:Mar 28, 2026

Use mysqldump to export database schemas and data from an ApsaraDB for SelectDB instance to a SQL file. The exported file contains CREATE DATABASE, CREATE TABLE, and INSERT statements, making it suitable for backup and small-scale migration.

Important

mysqldump is intended for development, testing, or small-scale data exports only. Do not use it in production environments with large datasets.

Prerequisites

Before you begin, make sure you have:

  • mysqldump installed (bundled with MySQL client tools)

  • The connection details for your ApsaraDB for SelectDB instance: host, port, and username

Export data

ApsaraDB for SelectDB does not support MySQL tablespaces. You must include --no-tablespaces in every mysqldump command.

Replace the placeholder values in the examples with your actual connection details:

PlaceholderDescriptionExample
<host>Hostname or IP address of your instance127.0.0.1
<port>Port number9030
<user>Database usernameroot

Export a specific table

mysqldump -h<host> -P<port> -u<user> --no-tablespaces --databases test_db --tables test_table

Export the schema only (no data)

mysqldump -h<host> -P<port> -u<user> --no-tablespaces --databases test_db --tables test_table --no-data

Export all tables in one or more databases

mysqldump -h<host> -P<port> -u<user> --no-tablespaces --databases test_db1 test_db2

Export all databases

mysqldump -h<host> -P<port> -u<user> --no-tablespaces --all-databases

Import data

To import a mysqldump file into an ApsaraDB for SelectDB instance:

  1. Export data to a file:

    mysqldump -h<host> -P<port> -u<user> --no-tablespaces --all-databases > all_databases.sql
  2. Connect to your ApsaraDB for SelectDB instance using the MySQL client, then run:

    source all_databases.sql

References