A question that came up during the MySQL track at the UKOUG
conference in Birmingham was "Can I exclude only a few databases
from mysqldump? Let's say that I have 50 databases, and I want to
dump all of them, except a few."
As many know, mysqldump has an option to ignore specific tables.
SO if you have 1,000 tables in a databases, you can tell
mysqldump to dump all the tables except a few ones.
There is no corresponding option to exclude one or more
databases.
However, if you know your command line tools, the solution is
easy:
First, we get the list of all databases:
mysql -B -N -e 'show databases'
information_schema
employees
five
four
mysql
one
performance_schema
six
test
three
two
-B forces batch mode (no dashes box around the data), while -N
gets the result without the headers.
Now, let's say that we want to exclude databases four, …