Created
October 5, 2021 12:21
-
-
Save joeydi/ec5bba96de3ad7a8625f51e0d387dad6 to your computer and use it in GitHub Desktop.
Export All MySQL Databases
This file contains hidden or 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
#!/bin/bash | |
USER="root" | |
PASSWORD="root" | |
ExcludeDatabases="Database|information_schema|performance_schema|mysql|sys" | |
databases=`mysql -u$USER -p$PASWORD -e "SHOW DATABASES;" | tr -d "| " | egrep -v $ExcludeDatabases` | |
for db in $databases; do | |
echo "Dumping database: $db" | |
mysqldump -u $USER -p$PASSWORD --databases $db > `date +%Y%m%d`.$db.sql | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment