MARIADB-DUMP(1)

πŸ’– mariadb-dump(1) β€” MariaDB Database System πŸ’–

okay bestie, welcome to the mariadb-dump page. This is the manual for the MariaDB Database System, and we're about to make backups make sense. Periodt.

🌸 NAME 🌸

mariadb-dump β€” a database backup program (and yes, the manpage literally says mariadb-dump is now a symlink to mariadb-dump, make it make sense πŸ’€).

✨ SYNOPSIS ✨

mariadb-dump [options] [db_name [tbl_name ...]]

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so mariadb-dump is this iconic client that's literally a backup program, and it was originally written by Igor Romanenko. You can use it to dump a database, or a whole collection of databases, for backup or to transfer to another SQL server β€” and no, that server doesn't have to be a MariaDB server, it's flexible like that. The dump usually contains SQL statements to create the table, populate it, or both. But also? mariadb-dump can generate files in CSV, other delimited text, or XML format. Versatile queen πŸ’…

If you're doing a backup on the server and all your tables are MyISAM tables, bestie consider using mariadb-hotcopy instead, because it can do faster backups and faster restores. See mariadb-hotcopy(1). No cap.

There are four general ways to invoke mariadb-dump:

shell> mariadb-dump [options] db_name [tbl_name ...]
shell> mariadb-dump [options] --databases db_name ...
shell> mariadb-dump [options] --all-databases
shell> mariadb-dump [options] --system={options}

If you don't name any tables after db_name, or if you use the --databases or --all-databases option, then entire databases get dumped. Like, the whole thing.

mariadb-dump does not dump the INFORMATION_SCHEMA or performance_schema databases by default. To dump these, you have to name them explicitly on the command line, and you must also use the --skip-lock-tables option. Don't forget that part, it's giving required.

To see a list of the options your version of mariadb-dump supports, just run mariadb-dump --help. Slay.

Some mariadb-dump options are just shorthand for groups of other options:

  • Using --opt is the same as specifying --add-drop-table, --add-locks, --create-options, --disable-keys, --extended-insert, --lock-tables, --quick, and --set-charset. And all of the options that --opt stands for are also on by default, because --opt is on by default. Recursive queen.
  • Using --compact is the same as specifying --skip-add-drop-table, --skip-add-locks, --skip-comments, --skip-disable-keys, and --skip-set-charset options.

To reverse the effect of a group option, you use its --skip-xxx form (--skip-opt or --skip-compact). You can also select only part of the effect of a group option by following it with options that enable or disable specific features. Here are some examples:

  • To select the effect of --opt except for some features, use the --skip option for each feature. To disable extended inserts and memory buffering, use --opt --skip-extended-insert --skip-quick. (Actually, --skip-extended-insert --skip-quick is sufficient because --opt is on by default.)
  • To reverse --opt for all features except index disabling and table locking, use --skip-opt --disable-keys --lock-tables.

When you selectively enable or disable the effect of a group option, order matters, because options are processed first to last. For example, --disable-keys --lock-tables --skip-opt would not have the intended effect; it's the same as --skip-opt by itself. Order is the moment.

mariadb-dump can retrieve and dump table contents row by row, or it can grab the entire content from a table and buffer it in memory before dumping it. Buffering in memory can be a problem if you're dumping large tables. To dump tables row by row, use the --quick option (or --opt, which enables --quick). The --opt option (and therefore --quick) is enabled by default, so to enable memory buffering, use --skip-quick.

If you're using a recent version of mariadb-dump to generate a dump that will be reloaded into a very old MySQL server, you should not use the --opt or --extended-insert option. Use --skip-opt instead. Trust.

mariadb-dump supports the following options, which you can specify on the command line or in the [mariadb-dump] and [client] option file groups. mariadb-dump also supports the options for processing option file. Okay now let's get into the options, bestie. There's a lot, but we're gonna get through them together 🫢

πŸ’– OPTIONS πŸ’–

  • --help, -? β€” Shows a help message and then exits. The classic.
  • --add-drop-database β€” Adds a DROP DATABASE statement before each CREATE DATABASE statement. This option is typically used together with the --all-databases or --databases option, because no CREATE DATABASE statements are written unless one of those options is specified. So like, it needs the context.
  • --add-drop-table β€” Adds a DROP TABLE statement before each CREATE TABLE statement. Clean slate energy.
  • --add-drop-trigger β€” Adds a DROP TRIGGER statement before each CREATE TRIGGER statement. Bye triggers, then hi triggers.
  • --add-locks β€” Surrounds each table dump with LOCK TABLES and UNLOCK TABLES statements. This makes inserts faster when the dump file is reloaded. Speed.
  • --all-databases, -A β€” Dumps all tables in all databases. It's the same as using the --databases option and naming all the databases on the command line. Everything, everywhere, all at once.
  • --all-tablespaces, -Y β€” Adds to a table dump all SQL statements needed to create any tablespaces used by an NDBCLUSTER table. This info is not otherwise included in the output from mariadb-dump. This option is currently relevant only to MySQL Cluster tables. Niche but valid.
  • --allow-keywords β€” Allows creation of column names that are keywords. It works by prefixing each column name with the table name. So your keyword columns can live their truth.
  • --apply-slave-statements β€” Adds 'STOP SLAVE' prior to 'CHANGE MASTER' and 'START SLAVE' to the bottom of the dump. Replication girlies know.
  • --as-of=name β€” Dumps system versioned table as of the specified timestamp. Time travel, but make it SQL.
  • --character-sets-dir=path β€” The directory where character sets are installed. Point it where they live.
  • --comments, -i β€” Writes additional information in the dump file, like program version, server version, and host. This option is enabled by default. To suppress this extra info, use --skip-comments. Default on, so if you don't want the tea, skip it.
  • --compact β€” Produces more compact output. This option enables the --skip-add-drop-table, --skip-add-locks, --skip-comments, --skip-disable-keys, and --skip-set-charset options. Minimalist queen.
  • --compatible=name β€” Produces output that is more compatible with other database systems or with older MySQL servers. The value of name can be ansi, mysql323, mysql40, postgresql, oracle, mssql, db2, maxdb, no_key_options, no_table_options, or no_field_options. To use several values, separate them by commas. These values have the same meaning as the corresponding options for setting the server SQL mode.

But wait β€” this option does not guarantee compatibility with other servers. It only enables those SQL mode values that are currently available for making dump output more compatible. For example, --compatible=oracle does not map data types to Oracle types or use Oracle comment syntax. So don't get it twisted.

  • --complete-insert, -c β€” Uses complete INSERT statements that include column names. Full send.
  • --compress, -C β€” Compresses all information sent between the client and the server, if both support compression. Zip it.
  • --copy-s3-tables β€” By default S3 tables are ignored. With this option set, the result file will contain a CREATE statement for a similar Aria table, followed by the table data and ending with an ALTER TABLE xxx ENGINE=S3. S3 girlies, this one's for you.
  • --create-options, -a β€” Includes all MariaDB-specific table options in the CREATE TABLE statements. Use --skip-create-options to disable. MariaDB flavor.
  • --databases, -B β€” Dumps several databases. Normally, mariadb-dump treats the first name argument on the command line as a database name and the following names as table names. With this option, it treats all name arguments as database names. CREATE DATABASE and USE statements are included in the output before each new database. Multi-db realness.
  • --debug[=debug_options], -# [debug_options] β€” Writes a debugging log. A typical debug_options string is 'd:t:o,file_name'. The default value is 'd:t:o,/tmp/mariadb-dump.trace'. Debug bestie.
  • --debug-check β€” Prints some debugging information when the program exits. Exit tea.
  • --debug-info β€” Prints debugging information and memory and CPU usage statistics when the program exits. Stats on stats.
  • --default-auth β€” Default authentication client-side plugin to use. Auth vibe.
  • --default-character-set=charset_name β€” Uses charset_name as the default character set. If no character set is specified, mariadb-dump uses utf8. Default is utf8, periodt.
  • --defaults-extra-file=filename β€” Sets filename as the file to read default options from after the global defaults files has been read. Must be given as first option. First or it doesn't count.
  • --defaults-file=filename β€” Sets filename as the file to read default options from, overriding global defaults files. Must be given as first option. Same energy.
  • --defaults-group-suffix=str, β€” Also read groups with a suffix of str. For example, since mariadb-dump normally reads the [client] and [mariadb-dump] groups, --defaults-group-suffix=x would cause it to also read the groups [mariadb-dump_x] and [client_x]. Group chat expansion.
  • --delayed-insert β€” Writes INSERT DELAYED statements rather than INSERT statements. Delayed but not forgotten.
  • --delete-master-logs β€” On a master replication server, deletes the binary logs by sending a PURGE BINARY LOGS statement to the server after performing the dump operation. This option automatically enables --master-data. Master energy.
  • --dir β€” Parallel dump of multiple databases. Works just like --tab, with regard to output (sql file for table definition and tab-separated for data, same options, e.g --parallel). It also allows the --databases and --all-databases options. When --dir is used, it creates the directory structure in the output directory pointed to by --dir. For every database to be dumped, there will be a directory with the database name. All options that --tab supports are also supported by --dir, in particular --parallel. Directory slay.
  • --disable-keys, -K β€” For each table, surrounds the INSERT statements with /*!40000 ALTER TABLE tbl_name DISABLE KEYS */; and /*!40000 ALTER TABLE tbl_name ENABLE KEYS */; statements. This makes loading the dump file faster because the indexes are created after all rows are inserted. This option is effective only for nonunique indexes of MyISAM tables. MyISAM girlies, this one's for you.
  • --dump-date β€” If the --comments option is given, mariadb-dump produces a comment at the end of the dump of the following form:
-- Dump completed on DATE

However, the date causes dump files taken at different times to appear to be different, even if the data are otherwise identical. --dump-date and --skip-dump-date control whether the date is added to the comment. The default is --dump-date (include the date in the comment). --skip-dump-date suppresses date printing. Date drama.

  • --dump-history β€” bestie, this one dumps your tables with their history. Before this option existed, mariadb-dump literally could not read historical rows out of versioned tables, so all that historical data just… wasn't getting backed up. πŸ’€ Not anymore. It's giving "we remember everything now." ✨
  • --dump-slave[=value] β€” for when you're making a dump off a replication slave server and you want that dump to be able to set up another slave pointed at the same master. 🫢 It appends the binary log position and filename of the master to the dumped data output.
    • Set the value to 1 (that's the default) and it prints as a CHANGE MASTER command right there in the dumped data output.
    • Set it to 2 and that command gets prefixed with a comment symbol.
    • This option turns --lock-all-tables on, unless you also specify --single-transaction (in which case a global read lock is only taken for a short time at the beginning of the dump β€” and bestie, don't forget to read about --single-transaction below, it's important πŸ‘€).
    • In all cases, any action on logs happens at the exact moment of the dump.
    • Option automatically turns --lock-tables off.
    • Using this option causes mariadb-dump to stop the slave SQL thread before beginning the dump, and restart it again after completion.
  • --events, -E β€” include Event Scheduler events for the dumped databases in the output. πŸŽ€
  • --extended-insert, -e β€” use the multiple-row INSERT syntax with several VALUES lists. Smaller dump file, faster inserts when you reload it. It's giving efficiency, periodt. πŸ”₯
  • --fields-terminated-by=..., --fields-enclosed-by=..., --fields-optionally-enclosed-by=..., --fields-escaped-by=... β€” these four cuties hang out with the --tab option and mean exactly the same thing as the corresponding FIELDS clauses for LOAD DATA INFILE. ✨
  • --first-slave β€” > πŸ’€ REMOVED in MariaDB 5.5. Use --lock-all-tables instead. She's gone, bestie, don't text her.
  • --flush-logs, -F β€” flush the MariaDB server log files before starting the dump. Needs the RELOAD privilege, so like… permission first. πŸ™ˆ
    • If you use this together with --all-databases, the logs get flushed for each database dumped.
    • The exception: when you're using --lock-all-tables or --master-data, the logs are flushed only once, matching the moment when all tables are locked.
    • If you want your dump and the log flush to happen at exactly the same moment, use --flush-logs together with either --lock-all-tables or --master-data. Synced. πŸ’…
  • --flush-privileges β€” sends a FLUSH PRIVILEGES statement to the server after dumping the mysql database. Use this any time your dump contains the mysql database and any other database that depends on the data in mysql to restore properly. Otherwise the vibes will be off and the restore will not slay. 🫢
  • --force, -f β€” keep going even if an SQL error happens during a table dump. She does not stop. πŸ‘‘
    • One use: making mariadb-dump keep executing even when it hits a view that's become invalid because its definition refers to a table that's been dropped. Without --force, mariadb-dump exits with an error message. With --force, it prints the error message, but also writes an SQL comment containing the view definition to the dump output, and keeps executing.
  • --gtid β€” available from MariaDB 10.0.13, and it's used together with --master-data and --dump-slave to more conveniently set up a new GTID slave. It makes those options output SQL statements that configure the slave to use the global transaction ID to connect to the master instead of the old-style filename/offset positions. Ngl, the old-style positions are still included in comments when --gtid is used β€” and likewise, the GTID position is included in comments even if --gtid is not used. Everyone gets a mention. πŸ’–
  • --header β€” used together with --tab. When enabled, adds a header with column names to the top of the output txt files. Cute little labels. πŸŽ€
  • --hex-blob β€” dump binary columns using hexadecimal notation (for example, 'abc' becomes 0x616263). The affected data types are BINARY, VARBINARY, the BLOB types, and BIT. 🌈
  • --host=host_name, -h host_name β€” dump data from the MariaDB server on the given host. The default host is localhost.
  • --ignore-table=db_name.tbl_name β€” do not dump the given table, and you must specify it using both the database and table names. To ignore multiple tables, use this option multiple times. This option also can be used to ignore views. ✨
  • --include-master-host-port β€” adds the MASTER_HOST and MASTER_PORT options for the CHANGE MASTER TO statement when you're using the --dump-slave option for a slave dump. 🫢
  • --insert-ignore β€” write INSERT IGNORE statements instead of INSERT statements. Different flavor, same energy. πŸ’…
  • --lines-terminated-by=... β€” this one is used with the --tab option and means the same thing as the corresponding LINES clause for LOAD DATA INFILE.
  • --lock-all-tables, -x β€” locks all tables across all databases. It does this by acquiring a global read lock for the whole duration of the dump. This option automatically turns off --single-transaction and --lock-tables. Full commitment. πŸ”’
  • --lock-tables, -l β€” for each dumped database, lock all the tables to be dumped before dumping them. Tables get locked with READ LOCAL so concurrent inserts are still allowed in the case of MyISAM tables. For transactional tables like InnoDB, --single-transaction is a much better option than --lock-tables, because it doesn't need to lock the tables at all. Bestie, listen. πŸ‘‘
    • Because --lock-tables locks tables for each database separately, this option does not guarantee that the tables in the dump file are logically consistent between databases. Tables in different databases may be dumped in completely different states. 😭
    • Use --skip-lock-tables to disable.
  • --log-error=file_name β€” log warnings and errors by appending them to the named file. The default is to do no logging.
  • --log-queries β€” when restoring the dump, the server will, if logging is turned on, log the queries to the general and slow query log. Defaults to on; use --skip-log-queries to disable.
  • --master-data[=value] β€” use this to dump a master replication server and produce a dump file that can set up another server as a slave of the master. It makes the dump output include a CHANGE MASTER TO statement indicating the binary log coordinates (file name and position) of the dumped server. Those are the master server coordinates the slave should start replicating from after you load the dump file into the slave. ✨
    • If the option value is 2, the CHANGE MASTER TO statement is written as an SQL comment, so it's informative only β€” it has no effect when the dump file is reloaded.
    • If the option value is 1, the statement is not written as a comment and it takes effect when the dump file is reloaded.
    • If no option value is specified, the default value is 1.
    • This option requires the RELOAD privilege and the binary log must be enabled. πŸ”₯
    • The --master-data option automatically turns off --lock-tables. It also turns on --lock-all-tables, unless --single-transaction is also specified. In all cases, any action on logs happens at the exact moment of the dump.
    • It's also possible to set up a slave by dumping an existing slave of the master. To do this, use the following procedure on the existing slave:
      1. Stop the slave's SQL thread and get its current status:
mariadb> STOP SLAVE SQL_THREAD;
mariadb> SHOW SLAVE STATUS;
  1. From the output of the SHOW SLAVE STATUS statement, the binary log coordinates of the master server from which the new slave should start replicating are the values of the Relay_Master_Log_File and Exec_Master_Log_Pos fields. Denote those values as file_name and file_pos.
  2. Dump the slave server:
shell> mariadb-dump --master-data=2 --all-databases > dumpfile
  1. Restart the slave:
mariadb> START SLAVE;
  1. On the new slave, load the dump file:
shell> mariadb < dumpfile
  1. On the new slave, set the replication coordinates to those of the master server obtained earlier:
mariadb> CHANGE MASTER TO
    -> MASTER_LOG_FILE = 'file_name', MASTER_LOG_POS = file_pos;

The CHANGE MASTER TO statement might also need other parameters, such as MASTER_HOST to point the slave to the correct master server host. Add any such parameters as necessary.

  • --max-allowed-packet=length β€” sets the maximum packet length to send to or receive from the server. πŸ“¦
  • --max-statement-time=seconds β€” sets the maximum time any statement can run before the server times it out. (Default value is 0 (no limit).)
  • --net-buffer-length=length β€” sets the buffer size for TCP/IP and socket communication.
  • --no-autocommit β€” wrap the INSERT statements for each dumped table inside SET autocommit = 0 and COMMIT statements. πŸŽ€
  • --no-create-db, -n β€” this option suppresses the CREATE DATABASE statements that would otherwise show up in the output if the --databases or --all-databases option is given.
  • --no-create-info, -t β€” do not write CREATE TABLE statements that re-create each dumped table.
  • --no-data, -d β€” do not write any table row information (that is, don't dump table contents). Super useful if you only want the CREATE TABLE statement for the table β€” for example, to create an empty copy of the table by loading the dump file. πŸ¦‹
  • --no-defaults β€” do not read default options from any option file. This must be given as the first argument, bestie, she's picky. πŸ‘‘
  • --no-set-names, -N β€” this has the same effect as --skip-set-charset.
  • --opt β€” shorthand! ✨ It's the same as specifying --add-drop-table --add-locks --create-options --disable-keys --extended-insert --lock-tables --quick --set-charset. It should give you a fast dump operation and produce a dump file that reloads into a MariaDB server quickly. She ate. πŸ’…
    • The --opt option is enabled by default. Use --skip-opt to disable it. See the discussion at the beginning of this section for info about selectively enabling or disabling a subset of the options affected by --opt.
  • --order-by-primary

okay bestie this next one dumps each table's rows sorted by its primary key, or by its first unique index, if such an index exists ✨ It's the move when you're dumping a MyISAM table that's gonna get loaded into an InnoDB table, but it will make the dump operation take considerably longer πŸ’… so like, plan accordingly.

  • --order-by-size β€” dump each table according to their size, smallest first πŸ“ Useful when using --single-transaction on tables which get truncated/altered often. The assumption here is that smaller tables get truncated more often, and by dumping those first, this reduces the chance that a --single-transaction dump will fail with with
  • --parallel=#, -j β€” number of dump table jobs executed in parallel (only for use with the --tab option) πŸ”₯ Initial testing indicates that performance can be increased (dump time decreased) up to 4 times on smaller size dumps, when the database fits into memory. There is a point at which disk becomes the bottleneck, after which adding more parallel jobs does not bring better performance. So like, more isn't always more, bestie 😭
  • --password[=password], -p[password] β€” the password to use when connecting to the server πŸ”‘ If you use the short option form (-p), you cannot have a space between the option and the password. If you omit the password value following the --password or -p option on the command line, mariadb-dump prompts for one.
Specifying a password on the command line should be considered insecure πŸ™ˆ You can use an option file to avoid giving the password on the command line.
  • --pipe, -W β€” on Windows, connect to the server via a named pipe. This option applies only if the server supports named-pipe connections.
  • --plugin-dir β€” directory for client-side plugins 🧩
  • --port=port_num, -P port_num β€” the TCP/IP port number to use for the connection. Forces --protocol=tcp when specified on the command line without other connection properties.
  • --protocol={TCP|SOCKET|PIPE|MEMORY} β€” the connection protocol to use for connecting to the server. It is useful when the other connection parameters normally would cause a protocol to be used other than the one you want ✨
  • --quick, -q β€” this option is useful for dumping large tables πŸƒβ€β™€οΈ It forces mariadb-dump to retrieve rows for a table from the server a row at a time rather than retrieving the entire row set and buffering it in memory before writing it out. Your RAM said thank you.
  • --print-defaults β€” print the program argument list and exit. This must be given as the first argument ⭐
  • --quote-names, -Q β€” quote identifiers (such as database, table, and column names) within β€œ<code></code>” characters. If the ANSI_QUOTES SQL mode is enabled, identifiers are quoted within β€œ"” characters. This option is enabled by default πŸ‘‘ It can be disabled with --skip-quote-names, but this option should be given **after** any option such as --compatiblethat may enable--quote-names`.
  • --replace β€” write REPLACE statements rather than INSERT statements πŸ”
  • --result-file=file_name, -r file_name β€” direct output to a given file πŸ“ This option should be used on Windows to prevent newline β€œ\n” characters from being converted to β€œ\r\n” carriage return/newline sequences. The result file is created and its previous contents overwritten, even if an error occurs while generating the dump πŸ’€
  • --routines, -R β€” include stored routines (procedures and functions) for the dumped databases in the output. Use of this option requires the SELECT privilege for the mysql.proc table. The output generated by using --routines contains CREATE PROCEDURE and CREATE FUNCTION statements to re-create the routines. However, these statements do not include attributes such as the routine creation and modification timestamps. This means that when the routines are reloaded, they will be created with the timestamps equal to the reload time πŸ•

If you require routines to be re-created with their original timestamp attributes, do not use --routines. Instead, dump and reload the contents of the mysql.proc table directly, using a MariaDB account that has appropriate privileges for the mysql database.

  • --set-charset β€” add SET NAMES default_character_set to the output. This option is enabled by default ✨ To suppress the SET NAMES statement, use --skip-set-charset.
  • --single-transaction β€” this option sends a START TRANSACTION SQL statement to the server before dumping data 🫢 It is useful only with transactional tables such as InnoDB, because then it dumps the consistent state of the database at the time when BEGIN was issued without blocking any applications.

When using this option, you should keep in mind that only InnoDB tables are dumped in a consistent state 😬 For example, any MyISAM or MEMORY tables dumped while using this option may still change state.

While a --single-transaction dump is in process, to ensure a valid dump file (correct table contents and binary log coordinates), no other connection should use the following statements: ALTER TABLE, CREATE TABLE, DROP TABLE, RENAME TABLE, TRUNCATE TABLE. A consistent read is not isolated from those statements, so use of them on a table to be dumped can cause the SELECT that is performed by mariadb-dump to retrieve the table contents to obtain incorrect contents or fail πŸ’€

The --single-transaction option and the --lock-tables option are mutually exclusive because LOCK TABLES causes any pending transactions to be committed implicitly.

To dump large tables, you should combine the --single-transaction option with --quick 🌸

  • --skip-add-drop-table β€” disable the --add-drop-table option.
  • --skip-add-locks β€” disable the --add-locks option.
  • --skip-comments β€” disable the --comments option.
  • --skip-compact β€” disable the --compact option.
  • --skip-disable-keys β€” disable the --disable-keys option.
  • --skip-extended-insert β€” disable the --extended-insert option.
  • --skip-opt β€” disable the --opt option.
  • --skip-quick β€” disable the --quick option.
  • --skip-quote-names β€” disable the --quote-names option.
  • --skip-set-charset β€” disable the --set-charset option.
  • --skip-triggers β€” disable the --triggers option.
  • --skip-tz-utc β€” disable the --tz-utc option.
  • --socket=path, -S path β€” for connections to localhost, the Unix socket file to use, or, on Windows, the name of the named pipe to use πŸ”Œ Forces --protocol=socket when specified on the command line without other connection properties; on Windows, forces --protocol=pipe.
  • --ssl β€” enable SSL for connection (automatically enabled with other flags). Disable with --skip-ssl πŸ”’
  • --ssl-ca=name β€” CA file in PEM format (check OpenSSL docs, implies --ssl).
  • --ssl-capath=name β€” CA directory (check OpenSSL docs, implies --ssl).
  • --ssl-cert=name β€” X509 cert in PEM format (check OpenSSL docs, implies --ssl).
  • --ssl-cipher=name β€” SSL cipher to use (check OpenSSL docs, implies --ssl).
  • --ssl-key=name β€” X509 key in PEM format (check OpenSSL docs, implies --ssl).
  • --ssl-crl=name β€” certificate revocation list (check OpenSSL docs, implies --ssl).
  • --ssl-crlpath=name β€” certificate revocation list path (check OpenSSL docs, implies --ssl).
  • --ssl-verify-server-cert β€” verify server's "Common Name" in its cert against hostname used when connecting. This option is disabled by default πŸ‘€
  • --system={all, users, plugins, udfs, servers, stats, timezones} β€” dump the system tables in the mysql database in a logical form πŸ—‚οΈ This option is an empty set by default.

One or more options can be listed in comma separated list.

The options here are:

  • all - an alias to enabling all of the below options.
  • users - the users, roles and their grants outputed as CREATE USER, CREATE ROLE, GRANT, and SET DEFAULT ROLE (ALTER USER for MySQL-8.0+).
  • plugins - active plugins of the server outputed as INSTALL PLUGIN.
  • udfs - user define functions outputed as CREATE FUNCTION.
  • servers - remote (federated) servers as CREATE SERVER.
  • stats - statistics tables, InnoDB and Engine Independent Table Statistics (EITS), are dumped as REPLACE INTO (or INSERT IGNORE if --insert-ignore is specified) statements without (re)creating tables.
  • timezones - timezone related system tables dumped as REPLACE INTO (or INSERT IGNORE if --insert-ignore is specified) statements without (re)creating tables.

The format of the output is affected by --replace and --insert-ignore. The --replace option will output CREATE OR REPLACE forms of SQL, and also DROP IF EXISTS prior to CREATE, if a CREATE OR REPLACE option isn't available.

With --system=user (or all), and --replace, SQL is generated to generate an error if attempting to import the dump with a connection user that is being replaced within the dump 🫠

The --insert-ignore option will cause CREATE IF NOT EXIST forms of SQL to generated if available.

For stats, and timezones, --replace and --insert-ignore have the usual effects.

Enabling specific options here will cause the relevant tables in the mysql database to be ignored when dumping the mysql database or --all-databases.

To help in migrating from MySQL to MariaDB, this option is designed to be able to dump system information from MySQL-5.7 and 8.0 servers 🚚 SQL generated is also experimentally compatible with MySQL-5.7/8.0. Mappings of implementation specific grants/plugins isn't always one-to-one however between MariaDB and MySQL and will require manual changes. So like, expect to do a lil hands-on work, bestie ✨

  • --tab=path, -T path β€” produce tab-separated text-format data files πŸ“„ For each dumped table, mariadb-dump creates a tbl_name.sql file that contains the CREATE TABLE statement that creates the table, and the server writes a tbl_name.txt file that contains its data. The option value is the directory in which to write the files.
Note: this option should be used only when mariadb-dump is run on the same machine as the mariadbd server. You must have the FILE privilege, and the server must have permission to write files in the directory that you specify. (iykyk β€” it's a whole permissions moment πŸ’…)

By default, the .txt data files are formatted using tab characters between column values and a newline at the end of each line. The format can be specified explicitly using the --fields-xxx and --lines-terminated-by options.

Column values are converted to the character set specified by the --default-character-set option.

  • --tables β€” Override the --databases or -B option. mariadb-dump regards all name arguments following the option as table names.
  • --triggers β€” Include triggers for each dumped table in the output. This option is enabled by default; disable it with --skip-triggers. (on by default, bestie, so if you don't want them you gotta say so)
  • --tz-utc β€” This option enables TIMESTAMP columns to be dumped and reloaded between servers in different time zones. mariadb-dump sets its connection time zone to UTC and adds SET TIME_ZONE='+00:00' to the dump file. Without this option, TIMESTAMP columns are dumped and reloaded in the time zones local to the source and destination servers, which can cause the values to change if the servers are in different time zones. --tz-utc also protects against changes due to daylight saving time. --tz-utc is enabled by default. To disable it, use --skip-tz-utc. (time zone chaos? not on our watch ✨)
  • --user=user_name, -u user_name β€” The MariaDB user name to use when connecting to the server.
  • --verbose, -v β€” Verbose mode. Print more information about what the program does. (she's chatty and we love that for her 🫢)
  • --version, -V β€” Display version information and exit.
  • --where='where_condition', -w 'where_condition' β€” Dump only rows selected by the given WHERE condition. Quotes around the condition are mandatory if it contains spaces or other characters that are special to your command interpreter. (mandatory means mandatory, no cap)

Examples:

--where="user='jimf'"
-w"userid>1"
-w"userid<1"
  • --xml, -X β€” Write dump output as well-formed XML.

NULL, 'NULL', and Empty Values: for a column named column_name, the NULL value, an empty string, and the string value 'NULL' are all distinguished from one another in the output generated by this option, like this:

  • NULL (unknown value) β†’ <field name="column_name" xsi:nil="true" />
  • '' (empty string) β†’ <field name="column_name"></field>
  • 'NULL' (string value) β†’ <field name="column_name">NULL</field>

The output from the mariadb client when run using the --xml option also follows the preceding rules. (See the section called "MARIADB OPTIONS".)

XML output from mariadb-dump includes the XML namespace, as shown here:

shell> mariadb-dump --xml -u root world City
<?xml version="1.0"?>
<mariadb-dump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<database name="world">
<table_structure name="City">
<field Field="ID" Type="int(11)" Null="NO" Key="PRI" Extra="auto_increment" />
<field Field="Name" Type="char(35)" Null="NO" Key="" Default="" Extra="" />
<field Field="CountryCode" Type="char(3)" Null="NO" Key="" Default="" Extra="" />
<field Field="District" Type="char(20)" Null="NO" Key="" Default="" Extra="" />
<field Field="Population" Type="int(11)" Null="NO" Key="" Default="0" Extra="" />
<key Table="City" Non_unique="0" Key_name="PRIMARY" Seq_in_index="1" Column_name="ID"
Collation="A" Cardinality="4079" Null="" Index_type="BTREE" Comment="" />
<options Name="City" Engine="MyISAM" Version="10" Row_format="Fixed" Rows="4079"
Avg_row_length="67" Data_length="273293" Max_data_length="18858823439613951"
Index_length="43008" Data_free="0" Auto_increment="4080"
Create_time="2007-03-31 01:47:01" Update_time="2007-03-31 01:47:02"
Collation="latin1_swedish_ci" Create_options="" Comment="" />
</table_structure>
<table_data name="City">
<row>
<field name="ID">1</field>
<field name="Name">Kabul</field>
<field name="CountryCode">AFG</field>
<field name="District">Kabol</field>
<field name="Population">1780000</field>
</row>
...
<row>
<field name="ID">4079</field>
<field name="Name">Rafah</field>
<field name="CountryCode">PSE</field>
<field name="District">Rafah</field>
<field name="Population">92020</field>
</row>
</table_data>
</database>
</mariadb-dump>

(okay that XML is lowkey giving art gallery, the indentation ate πŸ’…)

You can also set the following variables by using --var_name=value syntax:

  • max_allowed_packet β€” The maximum size of the buffer for client/server communication. The maximum is 1GB.
  • max_statement_time β€” A query that has taken more than max_statement_time seconds will be aborted and the backup will fail. The argument will be treated as a decimal value with microsecond precision. A value of 0 (default) means no timeout. The maximum timeout is 31536000 seconds. (yes bestie, you can absolutely set a timer on your queries, iconic)
  • net_buffer_length β€” The initial size of the buffer for client/server communication. When creating multiple-row INSERT statements (as with the --extended-insert or --opt option), mariadb-dump creates rows up to net_buffer_length length. If you increase this variable, you should also ensure that the net_buffer_length variable in the MariaDB server is at least this large.

A common use of mariadb-dump is for making a backup of an entire database:

shell> mariadb-dump db_name > backup-file.sql

You can load the dump file back into the server like this:

shell> mariadb db_name < backup-file.sql

Or like this:

shell> mariadb -e "source /path-to-backup/backup-file.sql" db_name

mariadb-dump is also very useful for populating databases by copying data from one MariaDB server to another:

shell> mariadb-dump --opt db_name | mariadb --host=remote_host -C db_name

It is possible to dump several databases with one command:

shell> mariadb-dump --databases db_name1 [db_name2 ...] > my_databases.sql

To dump all databases, use the --all-databases option:

shell> mariadb-dump --all-databases > all_databases.sql

For InnoDB tables, mariadb-dump provides a way of making an online backup:

shell> mariadb-dump --all-databases --single-transaction > all_databases.sql

This backup acquires a global read lock on all tables (using FLUSH TABLES WITH READ LOCK) at the beginning of the dump. As soon as this lock has been acquired, the binary log coordinates are read and the lock is released. If long updating statements are running when the FLUSH statement is issued, the MariaDB server may get stalled until those statements finish. After that, the dump becomes lock free and does not disturb reads and writes on the tables. If the update statements that the MariaDB server receives are short (in terms of execution time), the initial lock period should not be noticeable, even with many updates. (short lock moment, then she's free, we stan)

For point-in-time recovery (also known as "roll-forward," when you need to restore an old backup and replay the changes that happened since that backup), it is often useful to rotate the binary log or at least know the binary log coordinates to which the dump corresponds:

shell> mariadb-dump --all-databases --master-data=2 > all_databases.sql

Or:

shell> mariadb-dump --all-databases --flush-logs --master-data=2
              > all_databases.sql

The --master-data and --single-transaction options can be used simultaneously, which provides a convenient way to make an online backup suitable for use prior to point-in-time recovery if tables are stored using the InnoDB storage engine.

If you encounter problems backing up views, please read the section that covers restrictions on views which describes a workaround for backing up views when this fails due to insufficient privileges. (privileges said no? there's a workaround, go read that section bestie)


Copyright 2007-2008 MySQL AB, 2008-2010 Sun Microsystems, Inc., 2010-2025 MariaDB Foundation

This documentation is free software; you can redistribute it and/or modify it only under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License.

This documentation is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. (no warranty, fr fr, read it and weep 😭)

You should have received a copy of the GNU General Public License along with the program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA or see http://www.gnu.org/licenses/.


🌈 SEE ALSO 🌈

For more information, please refer to the MariaDB Documentation, available online at https://mariadb.com/docs/

πŸ‘‘ AUTHOR πŸ‘‘

MariaDB Foundation (http://www.mariadb.org/).


and that's the whole page, bestie!! this one's straight from MariaDB 11.8, dated 5 March 2025 β€” so you're fully caught up, no cap. go forth and dump responsibly πŸ¦‹πŸ’–βœ¨

πŸ“¦ where this page comes from