1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-03 07:08:01 +00:00

Add Dump A Database To A File as a mysql til

This commit is contained in:
jbranchaud
2017-06-06 19:34:38 -05:00
parent e061f8028c
commit be4d07ca5c
2 changed files with 22 additions and 1 deletions

View File

@@ -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)

View File

@@ -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`.