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!
- Load Average on Linux and Unix-like Systems Explained - May 16, 2020
- How to Install Webmin on CentOS/RHEL 7/6/5 – Linux - May 16, 2020
- List addon domains, parked domains and sub domains via command line – cPanel - May 13, 2020