16 Sep
MySQL dump tables like...
mysql $DB -u$USERNAME -p$PASSWORD -e 'show tables like "$LIKE%"' | grep -v Tables_in | xargs mysqldump --add-drop-table $DB -u$USERNAME -p$PASSWORD
Replace dollar variables with your details to drop a group of tables. Useful when you've got one database hosting a number of different web sites and you need a dump of a particular site.
You should follow me on Twitter here I'll tweet about JavaScript, HTML 5 and other such gems (amongst usual tweet-splurges)
This is my first code dump entry - I'll be trying to post these whenever I think the code is useful enough to share.
Note that the $dollar variables should be replaced as appropriate for your table dump.
Thanks!
Very useful!
Thanks, I needed to export some 200 tables from a 700 table database and I was already looking forward exporting them one by one
As being a newbie it took me some time to figure out that I had to extend your code with > filename to actualy save the mysqldump.
Regards
mysqldump -h $DBSource -u $USER -p$PASS $DB $TABLE --where='$Field > $VarStart AND $Field $TABLE$DumpName
Why cant i get this to run in Bash??
ive tried everything.. Can anyone help??
Hi,
Great tips (save my life for +/- 150 tables). I've added this options for thme "mysql" command to be more efficient (I hope
:
-s : silent (no border around the result)
--skip-column-names : no first line (no need to "grep")
Regards