Our blog
Updated MySQL Dump Splitter and Cleaner
My MySQL dump splitting script has come in handy countless times. Recently I also needed to remove keys from an SQL dump to enable me to import a dump that had keys associated with text columns.
Here is the updated script
*note - now updated again to strip out any drop table statements if splitting
-
<?php
-
/*MySQL Dump Split to Tables
-
* script supplied by Edmonds Commerce
-
* www.edmondscommerce.co.uk
-
* if you like it, please link back with a do-follow
-
*
-
* Now updated with better regex and also the ability to strip out keys other than the primary
-
*/
-
echo '<h1>MySQL Dump Split to Tables + Remove Keys</h1>';
-
echo '<form><b>Dump File Path:</b> <input name="dump_file"> <input type="submit" value="go"><select name="operation"><option value="split">split by tables</option><option value="keys">remove keys other than primary</option><option value="both">both</option></select></form>';
-
}else{
-
$pattern = '%,(s+?)KEY(.*?))%si';
-
$_GET['dump_file'] = 'nokeys.sql';
-
file_put_contents('nokeys.sql', $nokeys);
-
}
-
echo '<h3>Splitting File</h3>';
-
if ($handle) {
-
continue;
-
}
-
echo '. ';
-
}
-
$table_name = $matches[2];
-
}else{
-
}
-
}
-
}
-
}else{
-
echo 'no handle on file - does it exist - permissions...';
-
}
-
}
-
}
-
echo '<h1>Done</h1>'
-
?>
More...
Updated MySQL Dump Splitter and Cleaner | Edmonds Commerce Blog
Branedy » Blog Archive » WordPress MySQL exercises
Python Script to Backup MySql Databases (WordPress or other databases)
Importing Large MySQL Databases With BigDump
MySQL Upgrade: 1and1 is not the best host in the world | TheGarage ...
More Reading:
2 Comments
|
Hi, Thanks, Very nice stuff. But I cant understand what does this regular expression does? |
|
it lets us do one or both operations by specifying with the operation or both as the $_GET['operation'] |
RSS Feed
Math
October 21st, 2009