mysqldump: all database except 4..possible?

659 views
Skip to first unread message

DaNieL

unread,
Dec 17, 2008, 8:56:52 AM12/17/08
to Professional PHP Developers
hi guys, im new in here..
Im trying to move all mydata from the old server to the new one, and i
have some doubt for the databases.

actually i reach the new and the old servers by ssh terminal
connection, log into mysql shell, and launch mysqldump, in order to
move the sql file on the new server and restore it.

the problem is that for this week i have to dump the databases twice a
day for everyday, and i have almost 70 databases, plus 4 db that i
DONT WANT in the slq file... so i cant use
mysqldump -u $myuser -p --all-databases > myfile.sql
and using
mysqldump -u $myuser -p --databases $dbname1 $dbname2 $dbname3 >
myfile.sql
its a problem..
i saw the ignore option, but it works only for the tables (each db
have around 130 tables, cant use the ignore declaration -.-)

anyone know a way to dump all database except some, o how ignore them?
i mean something like mysqldump -u $myuser -p --all-database except/
ignore badDb1 badDb2 badDb3 > this_wont_work.sql?

Matthew Neilson

unread,
Dec 17, 2008, 11:16:41 AM12/17/08
to Professi...@googlegroups.com
Now this is a reach, but what if you tried using the --ignore-table command with a wildcard like this:

--ignore-table=db_to_skip.*

I tried to test that, but only have one database per username, so couldn't.

HTH,
Matt

DaNieL ...!

unread,
Dec 17, 2008, 11:38:02 AM12/17/08
to Professi...@googlegroups.com
oh.. ye, colud it be..
i dont think i'll ever thought so :D
i'll try tomorrow morning.. thanks for the idea!
(and sry for my bad english)

2008/12/17 Matthew Neilson <matt.n...@gmail.com>



--
Is cuma cá mhinice a théann tú ar strae; is é is tábhachtaí gurb áil leat do bhealach a aimsiú arís.

DaNieL ...!

unread,
Dec 17, 2008, 2:29:35 PM12/17/08
to Professi...@googlegroups.com
nah, it doesnt work..
if i launch
mysqldump -u admin -p --all-databases --ignore-table db_to_exclude1.* db_to_exclude2.* > myfile.sql
mysql return that cant find the second database (of course, the name is correct)
if i launch
mysqldump -u admin -p --all-databases --ignore-table db_to_exclude1.*  --ignore-table db_to_exclude2.* > myfile.sql
it works, but the dump file contain all the databases.. simply ignore the ignore declaration, or the jolly * char dont work in this case..


2008/12/17 Matthew Neilson <matt.n...@gmail.com>

Robert Gonzalez

unread,
Dec 17, 2008, 2:41:48 PM12/17/08
to Professi...@googlegroups.com
Can you create a user that has permissions for all but those 4 databases and see if that would do it? I am guessing that if the user doing the mysqldump does not have permissions to the database that the database server would not allow the database to be dumped. This is just a total guess though.
--
Robert A. Gonzalez

DaNieL ...!

unread,
Dec 17, 2008, 2:45:30 PM12/17/08
to Professi...@googlegroups.com
could work.. but doesnt handle any error?
well, i'll give a try..
i even thought so:
i dump first the database that i dont want, then i delete them, dump all database, and restore the unwanted.. but i suppose will create some errors with users, doesnt it?

the databases i dont want to dump are the horde, phpmyadmin_[...], pma, ecc...
all messy db on the old server that i dont want to see in the new one.

2008/12/18 Robert Gonzalez <robert.anth...@gmail.com>

DaNieL ...!

unread,
Dec 18, 2008, 3:07:34 AM12/18/08
to Professi...@googlegroups.com
oh great, it works!
fine, now i create the user once, grant the privileges, and then use he for the dumps!
thanks guys

2008/12/17 Robert Gonzalez <robert.anth...@gmail.com>
Reply all
Reply to author
Forward
0 new messages