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
--optis 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--optstands for are also on by default, because--optis on by default. Recursive queen. - Using
--compactis the same as specifying--skip-add-drop-table,--skip-add-locks,--skip-comments,--skip-disable-keys, and--skip-set-charsetoptions.
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
--optexcept for some features, use the--skipoption for each feature. To disable extended inserts and memory buffering, use--opt --skip-extended-insert --skip-quick. (Actually,--skip-extended-insert --skip-quickis sufficient because--optis on by default.) - To reverse
--optfor 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 aDROP DATABASEstatement before eachCREATE DATABASEstatement. This option is typically used together with the--all-databasesor--databasesoption, because noCREATE DATABASEstatements are written unless one of those options is specified. So like, it needs the context.--add-drop-tableβ Adds aDROP TABLEstatement before eachCREATE TABLEstatement. Clean slate energy.--add-drop-triggerβ Adds aDROP TRIGGERstatement before eachCREATE TRIGGERstatement. Bye triggers, then hi triggers.--add-locksβ Surrounds each table dump withLOCK TABLESandUNLOCK TABLESstatements. 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--databasesoption 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 frommariadb-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-charsetoptions. Minimalist queen.--compatible=nameβ Produces output that is more compatible with other database systems or with older MySQL servers. The value ofnamecan beansi,mysql323,mysql40,postgresql,oracle,mssql,db2,maxdb,no_key_options,no_table_options, orno_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 completeINSERTstatements 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 aCREATEstatement for a similar Aria table, followed by the table data and ending with anALTER TABLE xxx ENGINE=S3. S3 girlies, this one's for you.--create-options,-aβ Includes all MariaDB-specific table options in theCREATE TABLEstatements. Use--skip-create-optionsto disable. MariaDB flavor.--databases,-Bβ Dumps several databases. Normally,mariadb-dumptreats 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 DATABASEandUSEstatements are included in the output before each new database. Multi-db realness.--debug[=debug_options],-# [debug_options]β Writes a debugging log. A typicaldebug_optionsstring 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β Usescharset_nameas the default character set. If no character set is specified,mariadb-dumpusesutf8. Default isutf8, periodt.--defaults-extra-file=filenameβ Setsfilenameas 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β Setsfilenameas 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 ofstr. For example, sincemariadb-dumpnormally reads the[client]and[mariadb-dump]groups,--defaults-group-suffix=xwould cause it to also read the groups[mariadb-dump_x]and[client_x]. Group chat expansion.--delayed-insertβ WritesINSERT DELAYEDstatements rather thanINSERTstatements. Delayed but not forgotten.--delete-master-logsβ On a master replication server, deletes the binary logs by sending aPURGE BINARY LOGSstatement 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--databasesand--all-databasesoptions. When--diris 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--tabsupports are also supported by--dir, in particular--parallel. Directory slay.--disable-keys,-Kβ For each table, surrounds theINSERTstatements 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--commentsoption is given,mariadb-dumpproduces 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-dumpliterally 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 aCHANGE MASTERcommand right there in the dumped data output. - Set it to
2and that command gets prefixed with a comment symbol. - This option turns
--lock-all-tableson, 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-transactionbelow, it's important π). - In all cases, any action on logs happens at the exact moment of the dump.
- Option automatically turns
--lock-tablesoff. - Using this option causes
mariadb-dumpto stop the slave SQL thread before beginning the dump, and restart it again after completion.
- Set the value to
--events,-Eβ include Event Scheduler events for the dumped databases in the output. π--extended-insert,-eβ use the multiple-rowINSERTsyntax with severalVALUESlists. 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--taboption and mean exactly the same thing as the correspondingFIELDSclauses forLOAD DATA INFILE. β¨--first-slaveβ > π REMOVED in MariaDB 5.5. Use--lock-all-tablesinstead. She's gone, bestie, don't text her.--flush-logs,-Fβ flush the MariaDB server log files before starting the dump. Needs theRELOADprivilege, 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-tablesor--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-logstogether with either--lock-all-tablesor--master-data. Synced. π
- If you use this together with
--flush-privilegesβ sends aFLUSH PRIVILEGESstatement to the server after dumping themysqldatabase. Use this any time your dump contains themysqldatabase and any other database that depends on the data inmysqlto 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-dumpkeep 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-dumpexits 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.
- One use: making
--gtidβ available from MariaDB 10.0.13, and it's used together with--master-dataand--dump-slaveto 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--gtidis used β and likewise, the GTID position is included in comments even if--gtidis not used. Everyone gets a mention. π--headerβ used together with--tab. When enabled, adds a header with column names to the top of the outputtxtfiles. Cute little labels. π--hex-blobβ dump binary columns using hexadecimal notation (for example,'abc'becomes0x616263). The affected data types areBINARY,VARBINARY, theBLOBtypes, andBIT. π--host=host_name,-h host_nameβ dump data from the MariaDB server on the given host. The default host islocalhost.--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 theMASTER_HOSTandMASTER_PORToptions for theCHANGE MASTER TOstatement when you're using the--dump-slaveoption for a slave dump. π«Ά--insert-ignoreβ writeINSERT IGNOREstatements instead ofINSERTstatements. Different flavor, same energy. π--lines-terminated-by=...β this one is used with the--taboption and means the same thing as the correspondingLINESclause forLOAD 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-transactionand--lock-tables. Full commitment. π--lock-tables,-lβ for each dumped database, lock all the tables to be dumped before dumping them. Tables get locked withREAD LOCALso concurrent inserts are still allowed in the case of MyISAM tables. For transactional tables like InnoDB,--single-transactionis a much better option than--lock-tables, because it doesn't need to lock the tables at all. Bestie, listen. π- Because
--lock-tableslocks 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-tablesto disable.
- Because
--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-queriesto 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 aCHANGE MASTER TOstatement 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, theCHANGE MASTER TOstatement 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
RELOADprivilege and the binary log must be enabled. π₯ - The
--master-dataoption automatically turns off--lock-tables. It also turns on--lock-all-tables, unless--single-transactionis 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:
- Stop the slave's SQL thread and get its current status:
- If the option value is
mariadb> STOP SLAVE SQL_THREAD;
mariadb> SHOW SLAVE STATUS;
- From the output of the
SHOW SLAVE STATUSstatement, the binary log coordinates of the master server from which the new slave should start replicating are the values of theRelay_Master_Log_FileandExec_Master_Log_Posfields. Denote those values as file_name and file_pos. - Dump the slave server:
shell> mariadb-dump --master-data=2 --all-databases > dumpfile
- Restart the slave:
mariadb> START SLAVE;
- On the new slave, load the dump file:
shell> mariadb < dumpfile
- 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 is0(no limit).)--net-buffer-length=lengthβ sets the buffer size for TCP/IP and socket communication.--no-autocommitβ wrap theINSERTstatements for each dumped table insideSET autocommit = 0andCOMMITstatements. π--no-create-db,-nβ this option suppresses theCREATE DATABASEstatements that would otherwise show up in the output if the--databasesor--all-databasesoption is given.--no-create-info,-tβ do not writeCREATE TABLEstatements 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 theCREATE TABLEstatement 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
--optoption is enabled by default. Use--skip-optto 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.
- The
--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-transactionon 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-transactiondump will fail with with--parallel=#,-jβ number of dump table jobs executed in parallel (only for use with the--taboption) π₯ 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--passwordor-poption on the command line,mariadb-dumpprompts 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=tcpwhen 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 forcesmariadb-dumpto 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 theANSI_QUOTESSQL 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β writeREPLACEstatements rather thanINSERTstatements π--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 theSELECTprivilege for themysql.proctable. The output generated by using--routinescontainsCREATE PROCEDUREandCREATE FUNCTIONstatements 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β addSET NAMES default_character_setto the output. This option is enabled by default β¨ To suppress theSET NAMESstatement, use--skip-set-charset.--single-transactionβ this option sends aSTART TRANSACTIONSQL 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 whenBEGINwas 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-transactiondump 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 theSELECTthat is performed bymariadb-dumpto 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-tableoption.--skip-add-locksβ disable the--add-locksoption.--skip-commentsβ disable the--commentsoption.--skip-compactβ disable the--compactoption.--skip-disable-keysβ disable the--disable-keysoption.--skip-extended-insertβ disable the--extended-insertoption.--skip-optβ disable the--optoption.--skip-quickβ disable the--quickoption.--skip-quote-namesβ disable the--quote-namesoption.--skip-set-charsetβ disable the--set-charsetoption.--skip-triggersβ disable the--triggersoption.--skip-tz-utcβ disable the--tz-utcoption.--socket=path,-S pathβ for connections tolocalhost, the Unix socket file to use, or, on Windows, the name of the named pipe to use π Forces--protocol=socketwhen 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 themysqldatabase 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 asCREATE USER,CREATE ROLE,GRANT, andSET DEFAULT ROLE(ALTER USERfor MySQL-8.0+).plugins- active plugins of the server outputed asINSTALL PLUGIN.udfs- user define functions outputed asCREATE FUNCTION.servers- remote (federated) servers asCREATE SERVER.stats- statistics tables, InnoDB and Engine Independent Table Statistics (EITS), are dumped asREPLACE INTO(orINSERT IGNOREif--insert-ignoreis specified) statements without (re)creating tables.timezones- timezone related system tables dumped asREPLACE INTO(orINSERT IGNOREif--insert-ignoreis 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-dumpcreates atbl_name.sqlfile that contains theCREATE TABLEstatement that creates the table, and the server writes atbl_name.txtfile that contains its data. The option value is the directory in which to write the files.
Note: this option should be used only whenmariadb-dumpis run on the same machine as themariadbdserver. You must have theFILEprivilege, 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--databasesor-Boption.mariadb-dumpregards 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 enablesTIMESTAMPcolumns to be dumped and reloaded between servers in different time zones.mariadb-dumpsets its connection time zone to UTC and addsSET TIME_ZONE='+00:00'to the dump file. Without this option,TIMESTAMPcolumns 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-utcalso protects against changes due to daylight saving time.--tz-utcis 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 givenWHEREcondition. 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 is1GB.max_statement_timeβ A query that has taken more thanmax_statement_timeseconds will be aborted and the backup will fail. The argument will be treated as a decimal value with microsecond precision. A value of0(default) means no timeout. The maximum timeout is31536000seconds. (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-rowINSERTstatements (as with the--extended-insertor--optoption),mariadb-dumpcreates rows up tonet_buffer_lengthlength. If you increase this variable, you should also ensure that thenet_buffer_lengthvariable 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 π
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
- alpine 3.24: mariadb-doc 11.8.9-r0 Β· GPL-2.0-only
- arch rolling: mariadb-clients 13.0.2-2 Β· GPL-2.0-only
- arch rolling: mariadb-lts-clients 12.3.3-2 Β· GPL-2.0-only
- centos-stream 10: mariadb11.8 3:11.8.8-1.el10 Β· ( GPL-2.0-only OR Apache-2.0 ) AND ( GPL-2.0-or-later OR Apache-2.0 ) AND BSD-2-Clause AND BSD-3-Clause AND CC-BY-4.0 AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND ( GPL-3.0-or-later WITH Bison-exception-2.2 ) AND LGPL-2.0-only AND LGPL-2.0-or-later AND LGPL-2.1-only AND LGPL-2.1-or-later AND OpenSSL AND MIT AND OFL-1.1 AND CC0-1.0 AND PHP-3.0 AND PHP-3.01 AND zlib AND dtoa AND FSFAP AND blessing AND Info-ZIP AND Boehm-GC
- centos-stream 9: mariadb 3:11.8.8-1.module_el9+1370+ec5ecc2e Β· ( GPL-2.0-only OR Apache-2.0 ) AND ( GPL-2.0-or-later OR Apache-2.0 ) AND BSD-2-Clause AND BSD-3-Clause AND CC-BY-4.0 AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND ( GPL-3.0-or-later WITH Bison-exception-2.2 ) AND LGPL-2.0-only AND LGPL-2.0-or-later AND LGPL-2.1-only AND LGPL-2.1-or-later AND OpenSSL AND MIT AND OFL-1.1 AND CC0-1.0 AND PHP-3.0 AND PHP-3.01 AND zlib AND dtoa AND FSFAP AND blessing AND Info-ZIP AND Boehm-GC
- debian trixie: mariadb-client 1:11.8.6-0+deb13u1 Β· GPL-2.0-only
- fedora 43: mariadb11.8 3:11.8.8-1.fc43 Β· ( GPL-2.0-only OR Apache-2.0 ) AND ( GPL-2.0-or-later OR Apache-2.0 ) AND BSD-2-Clause AND BSD-3-Clause AND CC-BY-4.0 AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND ( GPL-3.0-or-later WITH Bison-exception-2.2 ) AND LGPL-2.0-only AND LGPL-2.0-or-later AND LGPL-2.1-only AND LGPL-2.1-or-later AND OpenSSL AND MIT AND OFL-1.1 AND CC0-1.0 AND PHP-3.0 AND PHP-3.01 AND zlib AND dtoa AND FSFAP AND blessing AND Info-ZIP AND Boehm-GC
- fedora 43: mariadb12.3 3:12.3.2-2.fc43 Β· ( GPL-2.0-only OR Apache-2.0 ) AND ( GPL-2.0-or-later OR Apache-2.0 ) AND BSD-2-Clause AND BSD-3-Clause AND CC-BY-4.0 AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND ( GPL-3.0-or-later WITH Bison-exception-2.2 ) AND LGPL-2.0-only AND LGPL-2.0-or-later AND LGPL-2.1-only AND LGPL-2.1-or-later AND OpenSSL AND MIT AND OFL-1.1 AND CC0-1.0 AND PHP-3.0 AND PHP-3.01 AND zlib AND dtoa AND FSFAP AND blessing AND Info-ZIP AND Boehm-GC
- fedora 44: mariadb 3:11.8.6-2.fc44 Β· ( GPL-2.0-only OR Apache-2.0 ) AND ( GPL-2.0-or-later OR Apache-2.0 ) AND BSD-2-Clause AND BSD-3-Clause AND CC-BY-4.0 AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND ( GPL-3.0-or-later WITH Bison-exception-2.2 ) AND LGPL-2.0-only AND LGPL-2.0-or-later AND LGPL-2.1-only AND LGPL-2.1-or-later AND OpenSSL AND MIT AND OFL-1.1 AND CC0-1.0 AND PHP-3.0 AND PHP-3.01 AND zlib AND dtoa AND FSFAP AND blessing AND Info-ZIP AND Boehm-GC
- fedora 44: mariadb 3:11.8.8-3.fc44 Β· ( GPL-2.0-only OR Apache-2.0 ) AND ( GPL-2.0-or-later OR Apache-2.0 ) AND BSD-2-Clause AND BSD-3-Clause AND CC-BY-4.0 AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND ( GPL-3.0-or-later WITH Bison-exception-2.2 ) AND LGPL-2.0-only AND LGPL-2.0-or-later AND LGPL-2.1-only AND LGPL-2.1-or-later AND OpenSSL AND MIT AND OFL-1.1 AND CC0-1.0 AND PHP-3.0 AND PHP-3.01 AND zlib AND dtoa AND FSFAP AND blessing AND Info-ZIP AND Boehm-GC
- fedora 44: mariadb12.3 3:12.3.2-2.fc44 Β· ( GPL-2.0-only OR Apache-2.0 ) AND ( GPL-2.0-or-later OR Apache-2.0 ) AND BSD-2-Clause AND BSD-3-Clause AND CC-BY-4.0 AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND ( GPL-3.0-or-later WITH Bison-exception-2.2 ) AND LGPL-2.0-only AND LGPL-2.0-or-later AND LGPL-2.1-only AND LGPL-2.1-or-later AND OpenSSL AND MIT AND OFL-1.1 AND CC0-1.0 AND PHP-3.0 AND PHP-3.01 AND zlib AND dtoa AND FSFAP AND blessing AND Info-ZIP AND Boehm-GC
- nixpkgs unstable: mariadb-server 11.8.8
- opensuse-leap 16.0: mariadb-client 11.8.8-160000.1.1 Β· SUSE-GPL-2.0-with-FLOSS-exception
- opensuse-leap 16.0: mariadb-client 11.8.8-160000.1.1 Β· SUSE-GPL-2.0-with-FLOSS-exception
- opensuse-leap 16.0: mariadb-client 11.8.8-160000.1.1 Β· SUSE-GPL-2.0-with-FLOSS-exception
- opensuse-leap 16.0: mariadb-client 11.8.8-160000.1.1 Β· SUSE-GPL-2.0-with-FLOSS-exception
- ubuntu resolute: mariadb-client 1:11.8.6-5 Β· GPL-2.0-only
- ubuntu resolute: mariadb-client 1:11.8.6-5ubuntu0.1 Β· GPL-2.0-only
- ubuntu stonking: mariadb-client 1:11.8.9+ds-4ubuntu2 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms