Skip to content

Instantly share code, notes, and snippets.

@yano3nora
Last active November 14, 2018 03:08
Show Gist options
  • Save yano3nora/8c073c4fe085f522f2c1f794efd143cb to your computer and use it in GitHub Desktop.
Save yano3nora/8c073c4fe085f522f2c1f794efd143cb to your computer and use it in GitHub Desktop.
[mysql: drop/dump/import] mysql data backup & import by command. #mysql #shell
# 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