Backup and Restore a Single Table in MySQL Database


Taking the backup of a single table of a MySQL database and restoring it is possible via command line. You might have done this using phpmyadmin or via other applications, let’s check how this can be done using the command line tool.

I am not writing too much, let’s directly move to the steps:
NOTE: Please take necessary backups before doing the below steps
Backup a single table from MySQL Database:

Run the following command to take table backup:

# mysqldump -u <Username> -p <password> <database-name> <Table-Name> < <File-Name>


# eg: mysqldump -u root -p ROOTPASS test_db test_db_table > test_db_table.sql

That’s all about taking backup. Now let’s see how to restore it.

Restore the table to MySQL database:

Run the following command to restore the table on your destination database:
# Mysql -u <Username_of_destination_DB> -p <Password_of_destination_DB> <DB_Name> < <Backup_file_name>

# mysql -u dest_user -pDESTPASS dest_db < test_db_table.sql

That’s all guys, happy linuxing!

Leave a Reply

Your email address will not be published. Required fields are marked *