Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save sumanthkumarc/a5e3c8d84e742db9969e35dd25a459f1 to your computer and use it in GitHub Desktop.
Save sumanthkumarc/a5e3c8d84e742db9969e35dd25a459f1 to your computer and use it in GitHub Desktop.
Naive parallel import of Compressed MYSQL dump file
# Split MYSQL dump file
zcat dump.sql.gz | awk '/DROP TABLE IF EXISTS/{n++}{print >"out" n ".sql" }'
# Parallel import using GNU Parallel http://www.gnu.org/software/parallel/
ls -rS *.sql | parallel --joblog joblog.txt mysql -uXXX -pYYY db_name "<"
@sumanthkumarc
Copy link
Author

easy to do instructions:
#zcat dump.sql.gz | awk '/DROP TABLE IF EXISTS/{n++}{print >"out" n ".sql" }'
#command above splits your db into multiple files, so better create a folder , put your dump.sql.gz file(ie., rename to dump.sql and then compress to gz format, if you don't want/know editing above command!!!)

#ls -rS *.sql | parallel --joblog joblog.txt mysql -uXXX -pYYY db_name "<"
Running this command , imports all you tables using parallel. Create an empty database and Put database username and password and database name you just created in above command.

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