How To Take Backup/Dump MySQL Databases?

This post describes how to take backup/dump MySQL database by using mysqldump and create SQL-format dump files.

By default, mysqldump writes information as SQL statements to the standard output. You can save the output in a file:

# mysqldump [arguments] > file_name

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

# mysqldump –all-databases > dump.sql

To dump only specific databases, use –databases option with database name:

# mysqldump –databases db1 db2 db3 > dump.sql

The –databases option causes all names on the command line to be treated as database names. Without this option, mysqldump treats the first name as a database name and those following as table names.

In the single-database case, it is permissible to omit the –databases option:

# mysqldump test > dump.sql

The difference between the two preceding commands is that without –databases, the dump output contains no CREATE DATABASE or USE statements.

Was this answer helpful? 0 Users Found This Useful (0 Votes)

Powered by WHMCompleteSolution