Split a mysql dump in databases
Hello,
I once needed to split a mysql dump in to multiple files, one per database so i used this awk one liner.
awk -F'`' '{if ($0 ~ /^– Current Database:/) db=$2; print >> db"-split.sql"}' mysql_dump.sql If you need to split one table from one database you can try the following bash scripts
!/bin/bash export DATABASE="$1" export TABLE="$2" echo $DATABASE echo $TABLE awk '/Table structure for table .'$TABLE'.$/,/UNLOCK TABLES/{print}' $DATABASE-split.sql
One minute to read