- To: slug@xxxxxxxxxxx
- Subject: Re: [SLUG] Splitting MySQL dump
- From: Jamie Wilkinson <jaq@xxxxxxxxxxxxxx>
- Date: Thu, 11 May 2006 01:30:17 +1000
- User-agent: Mutt/1.5.11+cvs20060403
This one time, at band camp, Rob Sharp wrote:
>I'm thinking I somehow need to split this file into manageable chunks to
>import it, but the script I coded in PHP can't handle files of that size.
>
>Anyone have any pointers on how I can split the file based on the string
>'CREATE TABLE' or something like that? A file per table would be fine to
>import.
To get the line numbers of the CREATE lines:
zgrep -n '^CREATE DATABASE' dump.sql.gz
Split at the line numbers:
zcat dump.sql.gz | sed -n 'LINE1,LINE2p' > somewhere
Theres probably some better magic you can do with csplit.