How can I get a specific mysqldump table?

368    Asked by CamelliaKleiber in SQL Server , Asked on Sep 29, 2022

How can I dump a specific table or set of tables without including the rest of the db tables?

Answered by Cameron Oliver

When you have more than a few tables in mysqldump table it is much better running something like this:


mysql database name -u [user] -p[password] -e 'show tables like "table_name_%"'

       | grep -v Tables_in

  <strong>       | xargs mysqldump [databasename] -u [root] -p [password] > [target_file]</strong>

Or something like this:

mysqldump -u [user] -p[password] databasename `echo "show tables like 'table_name_%';" 
       | mysql -u[user] -p[password] databasename
       | sed '/Tables_in/d'` > [target_file]

Remember that those commands must be typed in one line only.



Your Answer

Interviews

Parent Categories