Para restaurar uma única tabela de um dump MYSQL contendo diversas tabelas, pode-se usar a seguinte estratégia:
- Quando utilizar o DROP/CREATE da tabela
gzip -dc <arquivo.sql.gz> | sed -n -e '/DROP TABLE.*`<tabela>`/,/UNLOCK TABLES/p' > mytable.sql
mysql -u root -p'password' mydatabase < mytable_restore.sql
- Quando for apenas INSERT da tabela
gzip -dc <arquivo.sql.gz> | sed -n -e '/LOCK TABLES `<tabela>`/,/UNLOCK TABLES/p' > mytable.sql
mysql -u root -p'password' mydatabase < mytable_restore.sql
Nenhum comentário:
Postar um comentário