Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We want to export a large amount of tables and routines and we've do this often. Each database, table and routine should be dumped with one exception: a procedure with a specific name. So I was wondering, is there a way to exclude only procedure from the dump?

For tables there is an "ignore-table" option in MySQL. Is there something similar or a workaround to do this for one procedures in particular?

share|improve this question
up vote 1 down vote accepted

There is no built-in way to do so with mysqldump. However, all is not lost, you should be able to get away with it using sed.

Let's say your routine is a function, which is called split_token. The following code:

mysqldump --all-databases ... | sed "/DROP FUNCTION IF EXISTS \`split_token\`/,/^DELIMITER ;$/d"

will disregard the lines starting with DROP FUNCTION... and until the DELIMITER statement which ends the function's definition.

The above does not verify:

  1. A function of the same name may exist in multiple databases
  2. The text may appear within a string -- need better regexp matching (try and match the code starting the line using ^ -- look at the following line:

    /*!50003 DROP FUNCTION IF EXISTS split_token */;

Leaving this up to you to find the best regular expression.

share|improve this answer
Thanks! This should work. However we are using Windows - so we can't use 'sed'. At least to my knowlegde Windows doesn't have a similar command. But I think this should help out: – user18247 Jan 23 '13 at 10:22
Take a look at cygwin. It's been a while since I last used it (and a while since I last used Windows) -- but it should do the trick. – Shlomi Noach Jan 23 '13 at 17:58

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.