Select only interesting table from mysqldump

I’ve had this problem many times: 

A table is crashed but I’m only having the complete mysqldump of the database. There is no need to import the full database, so it would be great to select only the neccessary table and import it. 
If you’re having a gzipped sqldump, you could zcat and sed for getting the needed table-sql into a new file. Here is an example for how to solve this little problem:

zcat database-dump.sql.gz | sed -n -e '/CREATE TABLE.*interesting_table/,/CREATE TABLE/p' > interesting_table.sql

That’s it!

Das könnte Dich auch interessieren …

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.

Time limit is exhausted. Please reload the CAPTCHA.