If we are looking to dump just some tables of a database which have a common text string in their table names we can use this command:
mysql databasename -u [root] -p[password] -e 'show tables like "com_usr_%"' | grep -v Tables_in | xargs mysqldump [databasename] -u [root] -p[password] > [target_file]
It will grep all tables containing com_usr_*” and dump this into the target file.
If we want to dump a just a handful of tables then we can use this easier one:
mysqldump -u{user} -p {database} {table1} {table2} {table3} > target_file.sql
And finally a single table dump would simplify to this:
mysqldump -u{user} -p {database} {table} > target_file.sql
No comments:
Post a Comment
Hi, Leave a comment here and one of the binary piper's will reply soon :)