From be4d07ca5c02cf342b4be1e7c031f069d43aab44 Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Tue, 6 Jun 2017 19:34:38 -0500 Subject: [PATCH] Add Dump A Database To A File as a mysql til --- README.md | 3 ++- mysql/dump-a-database-to-a-file.md | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 mysql/dump-a-database-to-a-file.md diff --git a/README.md b/README.md index 8dda142..28262b4 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ smart people at [Hashrocket](http://hashrocket.com/). For a steady stream of TILs from a variety of rocketeers, checkout [til.hashrocket.com](https://til.hashrocket.com/). -_537 TILs and counting..._ +_538 TILs and counting..._ --- @@ -232,6 +232,7 @@ _537 TILs and counting..._ ### MySQL - [Display Output In A Vertical Format](mysql/display-output-in-a-vertical-format.md) +- [Dump A Database To A File](mysql/dump-a-database-to-a-file.md) - [List Databases And Tables](mysql/list-databases-and-tables.md) - [Show Indexes For A Table](mysql/show-indexes-for-a-table.md) diff --git a/mysql/dump-a-database-to-a-file.md b/mysql/dump-a-database-to-a-file.md new file mode 100644 index 0000000..f57d64e --- /dev/null +++ b/mysql/dump-a-database-to-a-file.md @@ -0,0 +1,20 @@ +# Dump A Database To A File + +The `mysqldump` client is a handy tool for creating a backup or snapshot of +a MySQL database. The standard use of this command produces an alphabetical +series of statements that comprise the structure and data of the specified +database. It directs all of this to `stdout`. You'll likely want to redirect +it to a file. + +```bash +$ mysqldump my_database > my_database_backup.sql +``` + +The output will include special comments with MySQL directives that disable +things like constraint checking. This is what allows the output to be in +alphabetical order without necessarily violating any foreign key +constraints. + +If you need to dump multiple databases, include the `--databases` flag with +a space-separated list of database names. Or dump all of them with +`--all-databases`.