Eg to extract the database OPALGATEWAY from the dump file all-06-11-11-17:00-mk-staging-1.sql.gz .
zcat all-06-11-11-17:00-mk-staging-1.sql.gz | awk '{ if ( $0 ~ /CREATE DATABASE.*OPALGATEWAY.*/ ) a=1; if ( $0 ~ /CREATE DATABASE / && $0 !~ /CREATE DATABASE.*OPALGATEWAY.*/ ) a=0; if (a==1) print $0 }' | gzip - | cat - > /tmp/OPALGATEWAY.sql.gz
I wrote about a similar issue in 2011: http://databaseblog.myname.nl/2011/03/restore-full-mysqldump-file-wo-mysql.html
ReplyDeleteI think 'gzip - | cat - >' can be replaced with 'gzip - >'
Related RFE bugs:
Bug #45003 dump-file-per-database
Bug #6945 dump-file-per-table