Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
split sql dump add transaction
#!/bin/sh
split -l 5000 dbdump.sql
find ./x* -type f -print0 | while IFS= read -r -d '' filename;\
do sed -i '1s/^/\n\nSET FOREIGN_KEY_CHECKS=0;\nSET SQL_MODE = \"NO_AUTO_VALUE_ON_ZERO\";\nSET AUTOCOMMIT = 0;\nSET time_zone = \"+00:00\";\nSTART TRANSACTION;\n\n /' $filename;\
done
find ./x* -type f -print0 | while IFS= read -r -d '' filename;\
do sed -i '$s/$/\n\nCOMMIT;\nSET FOREIGN_KEY_CHECKS=1;\n\n /' $filename;\
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment