NYCPHP Meetup

NYPHP.org

[nycphp-talk] Re: can mysqldump exclude a database?

Dan Cech dcech at phpwerx.net
Thu Oct 28 23:27:13 EDT 2004


Faber Fedor wrote:
> On 28/10/04 22:57 -0400, Daniel Convissor wrote:
>>Hey Folks:
>>
>>mysqldump -A will export all of the databases.  But, what if I want to 
>>exclude a particular database?  Is it possible?  How, please?
> 
> Is there a way to A) list all the databases (databasi?), B) run the
> output through 'grep -v' and then C) mysqldump the result?

Assuming your db password is mypass, and the database you want to 
exclude is test, the following should do the trick:

mysql --password=mypass -B --skip-column-names -e'SHOW DATABASES' | grep 
-v 'test' | xargs -n 1 "mysqldump" "--password=mypass" > nottest.sql

Dan



More information about the talk mailing list