How to dump only specific tables from MySQL?

Mysql

Mysql Problem Overview


If my database has 10 tables and I want to dump only 3 tables. Is it possible with mysqldump command?

Mysql Solutions


Solution 1 - Mysql

Usage: mysqldump [OPTIONS] database [tables]

i.e.

mysqldump -u username -p db_name table1_name table2_name table3_name > dump.sql

Solution 2 - Mysql

If you're in local machine then use this command

/usr/local/mysql/bin/mysqldump -h127.0.0.1 --port = 3306 -u [username] -p [password] --databases [db_name] --tables [tablename] > /to/path/tablename.sql;

For remote machine, use below one

/usr/local/mysql/bin/mysqldump -h [remoteip] --port = 3306 -u [username] -p [password] --databases [db_name] --tables [tablename] > /to/path/tablename.sql;

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionHarish KurupView Question on Stackoverflow
Solution 1 - MysqlLauri LehtinenView Answer on Stackoverflow
Solution 2 - MysqlRaja BoseView Answer on Stackoverflow