Skip to content

Instantly share code, notes, and snippets.

@PaulMorel
Created October 9, 2022 16:42
Show Gist options
  • Save PaulMorel/f9e08d30e6c4c67217d4e9e0c61a707e to your computer and use it in GitHub Desktop.
Save PaulMorel/f9e08d30e6c4c67217d4e9e0c61a707e to your computer and use it in GitHub Desktop.
One liner to import my specific structure of MySQL dumps for Devilbox
for i in *.sql.gz; do DB=$(grep -oP '\d{4}_\K[^.]*' <<<"$i"); echo "Importing $DB"; mysql -h mysql -u root -e "CREATE DATABASE IF NOT EXISTS $DB"; zcat "$i" | mysql -h mysql -u root "$DB"; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment