How to take a backup of single table in MySQL or MairaDB by using mysqldump

How to backup single table in MariaDB by using  mysqldump

Often as DBAs have to run delete, update or insert statements on a table, it is always good idea to take the backup of a table before running any DML statements. Below syntax can be used to take the backup of a table in Mysql or MairaDB. mysqldump will  create the file which will have drop table, create table and then insert statements for each line. If your table is huge, it can take long time to take the backup and also restore can be lengthy process.

Syntax:

mysqldump --user=username --password --lock-tables DatabaseName TableName > /tmp/FileName.sql

Example:

If I have a database name TechBrothers and one of the table is Emp that I need to take backup in tmp direcotry, I can use below script.
mysqldump --user=root --password --lock-tables DBA Emp > /tmp/Emp.sql
In above example, I have used root user, you can use the any user which has permission to take backup. you will be prompted for password after running above script.

Video Demo : How to take backup of Single Table in MairaDB or MySQL by using mysqldump

1 comment: