php

Mysql Dump Splitter

Stephen
After trying to import massive db dumps and it taking for ever i came up with a script to chop up a mysql dump at the table level. This allows me to import the dumps table by table, allowing for a multi threaded import rather than a single threaded import. #!/usr/bin/php <?php $start=time(); echo "MySQL Dump Split to Tables \r\n"; set_time_limit(600); $filetype=mime_content_type($argv[1]); if(!isset($argv[1])) { echo "Please provide dump file as a argument \r\n"; echo "If the 2nd argument is gzip it will compress the sql dumps of the tables \r\n"; exit(1); } if(isset($argv[2])) { if($argv[2] == "gzip") { $gzipoutput=true; } } if($filetype == "text/plain") { $handle = @fopen($argv[1], "r"); } else if($filetype == "application/x-gzip") { $handle = @gzopen($argv[1], "r"); } else { echo "Please provide a sql or gzip compressed sql file \r\n"; exit(1); } $header=true; if ($handle) { while (!