Skip to content

Instantly share code, notes, and snippets.

@albabar
Created March 28, 2014 18:23
Show Gist options
  • Select an option

  • Save albabar/9839584 to your computer and use it in GitHub Desktop.

Select an option

Save albabar/9839584 to your computer and use it in GitHub Desktop.
List all Database and export/dump them to individual SQL files.
#!/bin/sh
for db in $(mysql -u root -pROOTPASS -e 'show databases' -s --skip-column-names);
do
mysqldump -u root -pROOTPASS $db > $db-$(hostname)-$(date +%F-%s).sql
done
#!/bin/sh
mysql -u root -pROOTPASS -e 'show databases' -s --skip-column-names
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment