Nov 10, 2018

How to Restore MySQL database

Create file to execute prior to the dump file:

echo 'SET AUTOCOMMIT = 0;
SET FOREIGN_KEY_CHECKS=0;
' > pre.sql

Create a file to execute after the dump file is imported:

echo 'SET FOREIGN_KEY_CHECKS = 1;
COMMIT;
SET AUTOCOMMIT = 1;
' > post.sql

cat pre.sql dumpfile.sql post.sql | mysql database