Here I am going to export 3 tables from database named myDB in an sql file named table.sql
mysqldump -u root -p myDB table1 table2 table3 > table.sql
Quoting this link: http://steveswanson.wordpress.com/2009/04/21/exporting-and-importing-an-individual-mysql-table/
To export the table run the following command from the command line:
mysqldump -p --user=username dbname tableName > tableName.sql
This will export the tableName to the file tableName.sql.
To import the table run the following command from the command line:
mysql -u username -p -D dbname < tableName.sql
The path to the tableName.sql needs to be prepended with the absolute path to that file. At this point the table will be imported into the DB.
In case you encounter an error like this
mysqldump: 1044 Access denied when using LOCK TABLES
A quick workaround is to pass the –-single-transaction
option to mysqldump
.
So your command will be like this.
mysqldump --single-transaction -u user -p DBNAME > backup.sql
Source: Stackoverflow.com