Skip to content

Instantly share code, notes, and snippets.

@douglasmiranda
Last active September 5, 2019 09:29
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 douglasmiranda/1913266 to your computer and use it in GitHub Desktop.
Save douglasmiranda/1913266 to your computer and use it in GitHub Desktop.
MySQL - Export and Import free of troubles with Foreign Key Restriction From innoDB Tables
# Export and pack
mysqldump -uUSER -pPASSWORD database_name --compact --host=HOST_IP_ADDRESS | gzip > mysqlbackup.sql.gz
# Unpack
gunzip mysqlbackup.sql.gz
# Importing free of troubles with Foreign Key Restriction From innoDB Tables
mysql -uUSER -pPASSWORD
# MySQL terminal
mysql> CREATE DATABASE database_name CHARACTER SET utf8 COLLATE utf8_general_ci;
mysql> USE database_name
mysql> SET foreign_key_checks = 0;
mysql> SOURCE mysqlbackup.sql
mysql> SET foreign_key_checks = 1;
# done! :-)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment