Skip to content

Instantly share code, notes, and snippets.

@nasrulhazim
Created October 29, 2020 11:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nasrulhazim/9b216f51351489b94586b9dd821a8a6f to your computer and use it in GitHub Desktop.
Save nasrulhazim/9b216f51351489b94586b9dd821a8a6f to your computer and use it in GitHub Desktop.
Import Large MySQL File
# create prepend sql commands
echo "set autocommit=0;set unique_checks=0;set foreign_key_checks=0;" > prepend.sql
# prepend huge.sql above commands
cat huge.sql >> prepend.sql
# create append sql commands
echo "set autocommit=1;set unique_checks=1;set foreign_key_checks=1;" > append.sql
# prepend huge.sql with append.sql
cat append.sql >> huges.sql
# import to mysql database
mysql -uroot -p database_name < huge.sql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment