Backup and Restore MySQL With Mysqldump - Servers For Hackers
Backup and Restore MySQL With Mysqldump - Servers For Hackers
Let's see how to backup and restore MySQL databases, with a few extra tricks, using the mysqldump tool.### Setup
MySQL:
PREVIOUS CURRENT
(https://serversforhackers.com/s/backup-and-recovery)
Con guring MySQL Backup and Restore MySQL
Replication with mysqldump
(https://serversforhackers.com/c/con guring-
mysql-replication)
https://serversforhackers.com/c/backup-and-restore-mysql-with-mysqldump 1/3
1/24/2018 Backup and Restore MySQL with mysqldump | Servers for Hackers
Backup
Basic usage:
Compress:
# gzip
mysqldump -u root -p some_database | gzip > some_database.sql.gz
# bzip
mysqldump -u root -p some_database | bzip2 > some_database.sql.bz2
https://serversforhackers.com/c/backup-and-restore-mysql-with-mysqldump 2/3
1/24/2018 Backup and Restore MySQL with mysqldump | Servers for Hackers
You can export one database and import it into another in one command:
# Schema only
# Maybe make two dumps - schema vs data
--no-data
Restore
Restoring from a backup is generally pretty easy. Usually you'll need to create a database to import into, but that's not always true
(if your export has a CREATE DATABASE statement in it, then it will also create a new database for you).
Side note, If you're interested in a service to help you manage MySQL-optimized, backup and (eventually)
replication-enabled database servers, sign up here to let me know (http://sqlops.launchrock.com/)! The idea is
to allow you to better manage your MySQL servers, taking advantage of many of MySQL's more advanced
options, especially around backup and recovery.
PREVIOUS CURRENT
(https://serversforhackers.com/s/backup-and-recovery)
Con guring MySQL Backup and Restore MySQL
Replication with mysqldump
(https://serversforhackers.com/c/con guring-
mysql-replication)
https://serversforhackers.com/c/backup-and-restore-mysql-with-mysqldump 3/3