Skip to content

Instantly share code, notes, and snippets.

@salaros
Created February 24, 2017 16:43
Show Gist options
  • Save salaros/0bac4557b21f112aa8b63c999b110e39 to your computer and use it in GitHub Desktop.
Save salaros/0bac4557b21f112aa8b63c999b110e39 to your computer and use it in GitHub Desktop.
Modifies a MySQL dump file (.sql) in order to improve its importing speed a little bit
#!/bin/bash
sed -i '1s;^;\n;' $1
sed -i '1s;^;\n;' $1
sed -i '1s/^/SET autocommit=0;\n/' $1
sed -i '1s/^/SET unique_checks=0;\n/' $1
sed -i '1s/^/SET foreign_key_checks=0;\n/' $1
echo '' >> $1
echo '' >> $1
echo '' >> $1
echo 'COMMIT;' >> $1
echo 'SET unique_checks=1;' >> $1
echo 'SET foreign_key_checks=1;' >> $1
echo 'SET autocommit=1;' >> $1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment