All Products
Search
Document Center

ApsaraDB RDS:RDS MySQL mysqldump options

Last Updated:Mar 28, 2026

ApsaraDB RDS for MySQL imposes permission restrictions on regular users, which means some standard mysqldump options behave differently or are unavailable. This page covers the options you need to configure correctly, the options that work as expected, and the options that are blocked — along with the error you'll see if you try them.

GTID options

Global Transaction Identifier (GTID) support was introduced in MySQL 5.6, along with the --set-gtid-purged option in the mysqldump utility.

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

Values:

  • ON — Always includes the SET @@GLOBAL.GTID_PURGED statement.

  • OFF — Never includes the statement.

  • AUTO (default) — Includes the statement for GTID-enabled instances; generates no GTID information for instances that are not started or do not support GTID.

If you are exporting to an RDS MySQL 5.5 instance, always set --set-gtid-purged=OFF. MySQL 5.5 does not support GTID, so using a MySQL 5.6 or later mysqldump client without this flag causes the following errors:

Error: Server has GTIDs disabled.

or

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 during the dump. InnoDB and TokuDB — the engines supported by ApsaraDB RDS for MySQL — support transactions, so a transaction-based dump is both safer and faster.

Use --single-transaction to dump InnoDB or TokuDB tables without acquiring table locks.

OptionDefaultValuesDescription
--lock-all-tablesFALSETRUE | FALSEAcquires a global read lock for the entire dump, making all tables in all databases read-only. Automatically disables --lock-tables and --single-transaction. Not supported on ApsaraDB RDS for MySQL — see Unsupported options.
--lock-tablesTRUETRUE | FALSELocks tables before dumping them. Use --skip-lock-tables to disable. When using --single-transaction, this option is automatically disabled.
--single-transactionFALSETRUE | FALSEStarts a transaction before dumping data, avoiding table locks. Automatically disables --lock-tables. Recommended for InnoDB and TokuDB tables.

Recommended command

The following command uses the recommended options for exporting data from an ApsaraDB RDS for MySQL instance:

mysqldump --no-defaults \
  -u <username> -p<password> \
  -h <instance_endpoint> -P 3306 \
  --set-gtid-purged=OFF \
  --single-transaction \
  --hex-blob \
  --databases <database_name>
  • --no-defaults — Reads only .mylogin.cnf, preventing option files from overriding your settings.

  • --set-gtid-purged=OFF — Required when the target instance does not support GTID (for example, RDS MySQL 5.5).

  • --single-transaction — Dumps InnoDB and TokuDB tables consistently without table locks.

  • --hex-blob — Exports binary columns in hexadecimal to avoid encoding issues when migrating between MySQL versions.

Character set

If no character set is specified, mysqldump defaults to UTF-8.

OptionDefaultValuesDescription
--default-character-setutf8Any character set supported by ApsaraDB RDS for MySQLSets the character set for the dump output.

Additional options

OptionDefaultValuesDescription
--no-defaultsReads only the .mylogin.cnf option file, ignoring all other option files.
--defaults-file=file_nameReads options from the specified file only.
--add-drop-databaseFALSETRUE | FALSEAdds a DROP DATABASE statement before each CREATE DATABASE statement in the dump.
--add-drop-tableTRUETRUE | FALSEAdds a DROP TABLE statement before each CREATE TABLE statement. Use --skip-add-drop-table to disable.
--add-locksTRUETRUE | FALSEWraps each table dump with LOCK TABLES ... WRITE and UNLOCK TABLES, which speeds up inserts when the dump is reloaded.
--compatible=nameansi | postgresql | oracle | mssqlProduces 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 and includes CREATE DATABASE and USE statements in the output. Without this option, the first name argument is treated as a database and subsequent names as tables.
--disable-keysTRUETRUE | FALSEWraps INSERT statements with ALTER TABLE ... DISABLE KEYS and ALTER TABLE ... ENABLE KEYS to speed up loading. Effective only for non-unique indexes on MyISAM tables.
--eventsFALSETRUE | FALSEIncludes scheduled events in the dump.
--extended-insertTRUETRUE | FALSECombines multiple single-row INSERT statements into a single multi-row INSERT.
--hex-blobFALSETRUE | FALSEExports BINARY, VARBINARY, and BLOB columns in hexadecimal notation. Add this option when migrating data between different MySQL versions to avoid encoding issues.
--ignore-table=db.tabTRUETRUE | FALSEExcludes the specified table or view from the dump. Format: database_name.table_name. Repeat the option to exclude multiple tables.
--max-allowed-packet24MB24MB1GBMaximum buffer size for communication between mysqldump and the ApsaraDB RDS for MySQL instance.
--no-create-dbFALSETRUE | FALSEOmits CREATE DATABASE statements from the dump.
--no-create-infoFALSETRUE | FALSEOmits CREATE TABLE statements from the dump.
--no-dataFALSETRUE | FALSEDumps the schema only, without table 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 a dump timestamp to the output when --comments is enabled (which is the default).
--routinesFALSETRUE | FALSEIncludes stored procedures and functions in the dump.
--result-fileTRUETRUE | FALSERedirects output to the specified file.
--set-charsetTRUETRUE | FALSEAdds SET NAMES default_character_set to the dump output.
--triggersTRUETRUE | FALSEIncludes triggers for each dumped table.

Unsupported options

The following options are not available to ApsaraDB RDS for MySQL regular users due to permission restrictions.

OptionReason
--all-databasesRegular users do not have permissions on certain tables in the mysql database (such as slow_log), so a full database dump fails. To export all user databases, use --databases and list each database explicitly.
--flush-logsRequires the RELOAD privilege, which is not granted to regular users.
--flush-privilegesNot applicable — ApsaraDB RDS for MySQL does not allow exporting the mysql database.
--lock-all-tablesRequires the RELOAD privilege, which is not granted to regular users.
--tab=dir_nameRequires mysqldump and the RDS instance to share the same physical machine, which is not the case in a managed environment.

Error messages

If you use --all-databases or --lock-all-tables:

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

If you use --flush-logs or --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)

Using `--tab` with `--no-data`

Although --tab=dir_name cannot be used for full data dumps, combining it with --no-data lets you export the CREATE TABLE statements for each table into individual .sql files:

# Export CREATE TABLE statements only (no data)
mysqldump --no-defaults \
  -u <username> -p<password> \
  -h <instance_endpoint> -P 3306 \
  --set-gtid-purged=OFF \
  --single-transaction \
  --tab=/tmp \
  --no-data \
  <database_name>

Using --tab without --no-data returns the following error:

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