Last active
September 5, 2019 09:29
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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