All Products
Search
Document Center

ApsaraDB RDS:RDS MySQL mysqldump options

Last Updated:Mar 28, 2026

This page describes the mysqldump options relevant to ApsaraDB RDS for MySQL, including recommended settings, RDS-specific constraints, and unsupported options.

Recommended command

For most exports from ApsaraDB RDS for MySQL, use the following command as a starting point:

mysqldump \
  --no-defaults \
  -u <user_name> \
  -p<password> \
  -h <instance_endpoint> \
  -P 3306 \
  --set-gtid-purged=OFF \
  --single-transaction \
  --routines \
  --triggers \
  --hex-blob \
  --databases <database_name> > dump.sql

Replace the placeholders with your actual values:

PlaceholderDescriptionExample
<user_name>Database accountroot
<password>Database account password
<instance_endpoint>Public or internal endpoint of the RDS instancexxx.mysql.rds.aliyuncs.com
<database_name>Name of the database to exportmydb
--set-gtid-purged=OFF is required when exporting from an instance with GTID enabled to an import target that does not support GTID (such as RDS MySQL 5.5). See GTID for details.

GTID

Global Transaction Identifiers (GTID) were introduced in ApsaraDB RDS for MySQL 5.6. The mysqldump bundled with MySQL 5.6 and later adds the --set-gtid-purged option to control whether GTID information is included in the dump output.

OptionDefaultValuesDescription
set-gtid-purgedAUTOON | OFF | AUTOControls whether a SET @@GLOBAL.GTID_PURGED statement is included in the dump output.

Value behavior:

  • `ON`: Includes a SET @@GLOBAL.GTID_PURGED statement in the output.

  • `OFF`: Excludes the SET @@GLOBAL.GTID_PURGED statement from the output.

  • `AUTO` (default): Includes the statement if the source instance has GTID enabled. For instances where GTID is not started or not supported, no GTID information is generated.

Cross-version export: When using MySQL 5.6 or later mysqldump to export data into an RDS MySQL 5.5 instance, set --set-gtid-purged=OFF. Otherwise, the import fails with one of the following errors:

Error: Server has GTIDs disabled.
mysqldump: Couldn't execute 'SELECT @@GTID_MODE': Unknown system variable 'GTID_MODE' <1193>

Locking options

By default, mysqldump enables --lock-tables, which locks all tables before dumping them and blocks DML operations for the duration of the dump.

InnoDB and TokuDB — the engines supported by ApsaraDB RDS for MySQL — support transactions. Use --single-transaction instead of --lock-tables or --lock-all-tables to avoid table-level locks.

OptionDefaultValuesDescription
lock-all-tablesFALSETRUE | FALSEAcquires a global read lock for the entire dump. All tables across all databases become read-only. Automatically disables --lock-tables and --single-transaction. Not supported on ApsaraDB RDS for MySQL.
lock-tablesTRUETRUE | FALSELocks tables before dumping them. Enabled by default. Use --skip-lock-tables to disable.
single-transactionFALSETRUE | FALSEStarts a transaction before dumping. Automatically disables --lock-tables. Recommended for InnoDB and TokuDB tables.

Character set

If no character set is specified, mysqldump uses UTF-8 by default.

OptionDefaultValuesDescription
default-character-setUTF8Any character set supported by ApsaraDB RDS for MySQLSets the character set for the export.

Additional options

OptionDefaultValuesDescription
no-defaultsReads the .mylogin.cnf option file only.
defaults-file=<file_name>Reads the specified option file.
add-drop-databaseFALSETRUE | FALSEAdds a DROP DATABASE statement before each CREATE DATABASE statement.
add-drop-tableTRUETRUE | FALSEAdds a DROP TABLE statement before each CREATE TABLE statement. Use --skip-add-drop-table to disable.
add-locksTRUETRUE | FALSESurrounds each table dump with LOCK TABLES ... WRITE and UNLOCK TABLES statements. Speeds up inserts when reloading the dump.
compatible=<name>ansi | postgresql | oracle | mssqlGenerates output compatible with the specified database type.
compactFALSETRUE | FALSEEnables --skip-add-drop-table, --skip-add-locks, --skip-comments, --skip-disable-keys, and --skip-set-charset.
databasesTRUETRUE | FALSETreats all name arguments as database names. Includes CREATE DATABASE and USE statements before each database in the output.
disable-keysTRUETRUE | FALSEWraps INSERT statements with ALTER TABLE ... DISABLE KEYS and ALTER TABLE ... ENABLE KEYS. Effective only for non-unique indexes on MyISAM tables.
eventsFALSETRUE | FALSEDumps scheduled events from the exported databases.
extended-insertTRUETRUE | FALSECombines single-row INSERT statements into multi-row INSERT statements for faster imports.
hex-blobFALSETRUE | FALSEExports BINARY, VARBINARY, and BLOB columns in hexadecimal notation. Use this option when migrating between different database versions.
ignore-table=<db.table>TRUETRUE | FALSEExcludes the specified table or view. Use the database.table format. Repeat the option to exclude multiple tables.
max-allowed-packet24MB24MB1GBMaximum size of the communication buffer between mysqldump and the RDS instance. Default is 24 MB; maximum is 1 GB.
no-create-dbFALSETRUE | FALSEExcludes CREATE DATABASE statements from the output.
no-create-infoFALSETRUE | FALSEExcludes CREATE TABLE statements from the output.
no-dataFALSETRUE | FALSEExports the schema only, without row data.
optTRUETRUE | FALSEShorthand that enables --add-drop-table, --add-locks, --create-options, --disable-keys, --extended-insert, --lock-tables, --quick, and --set-charset. Use --skip-opt to disable.
dump-dateTRUETRUE | FALSEAppends the dump date to the output when --comments is enabled (which it is by default).
routinesFALSETRUE | FALSEDumps stored procedures and functions. Not included by default.
result-fileTRUETRUE | FALSEDirects output to the specified file.
set-charsetTRUETRUE | FALSEAdds SET NAMES <default_character_set> to the output.
triggersTRUETRUE | FALSEIncludes triggers for each exported table.

Options not supported on ApsaraDB RDS for MySQL

The following options are not supported. Attempting to use them results in permission errors, because ApsaraDB RDS for MySQL accounts do not have the required privileges.

OptionReason
all-databasesRequires access to all tables in the mysql database. RDS MySQL accounts do not have the necessary permissions.
flush-logsRequires the RELOAD privilege, which RDS MySQL accounts do not have.
flush-privilegesNot applicable — ApsaraDB RDS for MySQL does not allow exporting the mysql database.
lock-all-tablesRequires the RELOAD privilege, which RDS MySQL accounts do not have.
tab=<dir_name>Requires mysqldump and the RDS instance to be on the same physical machine, which is not the case for RDS.

Error messages by option:

all-databases:

mysqldump: Couldn't execute 'show create table slow_log': SHOW command denied to user 'xxx'@'xx.xx.xx.xx' for table 'slow_log' (1142)

flush-logs and lock-all-tables:

mysqldump: Couldn't execute 'FLUSH TABLES': Access denied; you need (at least one of) the RELOAD privilege(s) for this operation (1227)

tab=<dir_name>:

mysqldump: Got error: 1045: Access denied for user 'xxx'@'%' (using password: YES) when executing 'SELECT INTO OUTFILE'

Partial workaround for `--tab`: Combine --tab with --no-data to export only the CREATE TABLE statements (.sql files) for each table, without data:

mysqldump \
  --no-defaults \
  -u <user_name> \
  -p<password> \
  -h <instance_endpoint> \
  -P 3306 \
  --set-gtid-purged=OFF \
  --single-transaction \
  --tab=/tmp \
  --no-data \
  <database_name>