| Home Profile Fun |
#186 Linux 07.08.2009
Import single database from MySQL dumpThe PHP script dumpsplit.php scans a MySQL dump in SQL format and displays all contained databases. The lines of the database you have selected will be extracted from the dump along with all lines that contain variables. This extraction can then be used to import the single database. I have tested it with latin1 and utf-8 tables. Nevertheless: DON'T USE IT IN PRODUCTION ENVIRONMENTS! USE IT AT YOUR OWN RISK! Installation: wget http://www.infosecprojects.net/en/linuxtutorials/dumpsplit.php_0.0.1 mv dumpsplit.php_0.0.1 dumpsplit.php chmod u+x ./dumpsplit.php Usage: ./dumpsplit.php mysqldump databaseThe result is a new dump called mysqldump__database.sql. It contains only those lines from the original dump which are relevant to the selected database. Then you can do the import: mysql -uroot -p < mysqldump__database.sql dumpsplit 0.0.1 download Example: dhcppc0:/test # ./dumpsplit.php dump.sql testdb I will scan mysql dump 'dump.sql' and copy all lines of database 'testdb' into new dump './dump.sql__testdb'. Scanning dump for databases ... Found: db12 Found: db13 Found: db14 :-) Found: testdb Found: mysql Found: test :-) Your database was found in the dump. Feedback is welcome: norbert.klein@infosecprojects.net |