If you need to export tables from MySQL, mysqldump is the tool for the job. This article will show you how to use mysqldump to export tables from a MySQL server. To export tables using mysqldump, you first need to connect to the MySQL server and create a dump file. The dump file will contain all of the tables on the server. To create a dump file, use the following command: mysqldump -u root -p [server_name] > [dump_file_name] The following example shows how to create a dump file for a MySQL server named testserver that is running on port 3306: mysqldump -u root -p testserver > testserver.dump ..
Logically we’d have moved those archive tables to a separate archive database, but that would be a lot of work and we just haven’t felt like it. Mmm Hot Pockets.
After looking at our database we realized that about 90% of the space was data that we really didn’t need on a testing environment, and most of that data was in a couple of tables.
The solution, of course, is to simply use mysqldump with the –ignore-table option. The one tricky thing that you need to keep in mind is that you have to use a dbname.tablename syntax, you can’t simply put the table name. Why? /shrug
If you want to exclude multiple tables, you can use the same argument more than once on the command line, like this:
You’d think that you could simply put the exclusions with spaces like you do when you specify only particular tables for export in the first place. But no, that would be too consistent.
To import that exported file again on another machine, you’d use something like this to run all the commands and inserts in the file: