From: AndrĂ©s Tello Date: February 20 2012 5:41pm Subject: How to split a mysqldump file of multiple databases to singlefile databases... SOLVED with script List-Archive: http://lists.mysql.com/mysql/226821 Message-Id: MIME-Version: 1.0 Content-Type: multipart/alternative; boundary=14dae9cdc3fbdffaac04b968cda4 --14dae9cdc3fbdffaac04b968cda4 Content-Type: text/plain; charset=ISO-8859-1 Today I needed to split a mysqldump -A into it several databases. I didn't have access to the original source, so I only had the texr file to work. It was a webhosting server dump, so there was a LOT of databases... I split the file with this little script I made: file= nextTable="" nextStart=0 nextEnd=0 lastTable="" lastStart=0 for i in `grep -n "^CREATE DATABASE" $file | awk '{print $1":"$7}' | sed "s/CREATE://g"` do i=`echo $i | sed "s/\\\`//g"` nextTable=`echo $i | cut -d : -f 2` nextStart=`echo $i | cut -d : -f 1` nextEnd=$(( $nextStart -1 )) if [ "$lastTable" != "" ] then echo "Tabla: $lastTable from: $lastStart to $nextEnd" sed -n ${lastStart},${nextEnd}p $file > new/$lastTable.portabla.sql fi lastTable=$nextTable lastStart=$(( $nextStart )) done --14dae9cdc3fbdffaac04b968cda4--