As a web developer, we sometimes may want to export a specific table from a MySQL database. It can be particularly helpful when we are going to apply some changes to a table that is part of a large database and we are interested in backing up that specific table only, rather that whole huge database.
To create a backup (also called dump) of the a table use this command:
mysqldump -u username -p db_name table_name | gzip > db_name.table_name.sql.gz
This will create the backup/dump for the table in the file in compressed format.
We can import back the table to the database as usual we do with normal database dumps:
gunzip -c db_name.table_name.sql.gz | mysql -u username -p db_name
Use the correct values for username, db_name and table_name.