MySQL dump, ignore all except tables and table data

Bobby used Ask the Experts™
How do I create a MySQL dump command line that ignores views, stored procs, triggers, everything except tables and table data? All I want to transfer from one db on a server to another db on a different server is table /drop /create and table data.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
nociSoftware Engineer
Distinguished Expert 2018

A Mysqldump is just a plain Tekst file with SQL statements.
You can remove all statements that you don't like from it.
(Due to the fairly rigid format this can be scripted without too much trouble).
mysqldump does not include data from views. only the table definition so it is not really a problem to transfer views as they cost nothing

you can skip individual views manually using --ignore-table

afaik there is no option to skip all views but you can easily list them with "show views" and exclude the returned list
Fractional CTO
Distinguished Expert 2018
Also triggers + events are excluded by default.

To include them you must specify --triggers + --events as mysqldump command line options.

Same applies to --routines, which relates to stored procedures.

This will also vary between mysql installations, as --events is fairly new, so many current installs don't even support the --events option.

Refer to your install docs for exact details.

In general, you'll have to come up with a procedure, like skullnobrains suggested, to exclude views + material views. Everything else you mentioned will be excluded by default (no --events or --triggers options passed).
theGhost_k8Database Consultant

Well apart from above comments did you know about mysqldumpsplitter? It is also there on git. That can be use full if you're already having the full dump.


Thanks all.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial