Skip to content

Instantly share code, notes, and snippets.

@steffenr
Last active November 2, 2015 19:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save steffenr/fd67611026ef022a02cb to your computer and use it in GitHub Desktop.
Save steffenr/fd67611026ef022a02cb to your computer and use it in GitHub Desktop.
Extract single table from mysql dump
# Extract CREATE / INSERT from default mysql dump.
zcat > dump.sql.gz | sed -n -e '/CREATE TABLE.*`my_table`/,/UNLOCK TABLES/p' > my_table.sql
# Extract INSERTs only.
zcat > dump.sql.gz | sed -n -e '/INSERT INTO `my_table`/,/UNLOCK TABLES/p' > my_table.sql
@steffenr
Copy link
Author

steffenr commented Nov 2, 2015

If you get the error sed: RE error: illegal byte sequence, you should set the following parameters in your ~/.bash_profile or ~/.zshrc.

export LC_CTYPE=C 
export LANG=C

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment