How to Backup MariaDB / MySQL DB using mysqldump on Ubuntu 16.04 / CentOS 7

How to Backup MariaDB / MySQL Database using mysqldump on Ubuntu 16.04 / CentOS 7 / RHEL 7 / Debian 9 / 8 . The MariaDB / MySQL Database are the most popular RDBMS (Relational Database Management System) and It is used by most of the Web Applications. That’s why backup plays most important aspect to secure your database. The mysqldump is the command that is useful to take backup in various output format. It is useful when all the backup is taken in single file that is useful for database restoration purpose. Also the mysqldump is also useful to take backup of data in various time interval using crontab to schedule backup of database. This tutorial explains how to take complete the database backup using mysqldb command.

Backup all the database

This command is useful when you take the compete backup of your database.

Syntax of command

# mysqldump –all-database -u databaseusername -p > path of destination where backup can be stored

Example command
# mysqldump --all-database -u databaseusername -p > /home/techbrown/full-backup.sql

Backup a single database

This command is very useful when you take backup of single selected database.

Syntax of command

# mysqldump -u databaseusername -p databasename > path of destination where backup can be stored

Example command
# mysqldump -u root -p techbrowndatabase > /home/techbrown/techbrowndatabase.sql

Backup a selected tables from a database

This command is very useful when you select the tables from a database and output in text format.

Syntax of command

# mysql databasename -e “SELECT tablename1, tablename2, tablename3 \ FROM databasename” > path of destination where backup can be stored

Example command
# mysql techbrowndatabase -e "SELECT user1, user2, user3 \ FROM techbrowndatabase" > /home/techbrown/techbrowndatabase.txt

Final Words

Finally you have completed all steps to enable the database backups using the mysqldump commands on your respective Linux distributions. Now you have to keep a backup ready to secure your system. If you have any queries then use the comment section for help and support.

Hot Right Now

Related Post

COMMENTS