Last active
November 14, 2018 03:08
-
-
Save yano3nora/8c073c4fe085f522f2c1f794efd143cb to your computer and use it in GitHub Desktop.
[mysql: drop/dump/import] mysql data backup & import by command. #mysql #shell
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
# drop | |
mysql -u${DB_USER} -p${DB_PASS} -D${DB_NAME} -N -e 'show tables' | xargs -IARG mysql -u${DB_USER} -p${DB_PASS} -e 'drop table ARG' -D${DB_NAME} | |
# dump | |
mysqldump --single-transaction -u ${USER} -p ${DB} > ${FILE}.sql | |
# import | |
mysql -u ${USER} -p ${DB} < ${FILE}.sql |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment