Download all MySQL Databases in respective sql files using mysqldump

  • https://ma.ttias.be/mysql-back-up-take-a-mysqldump-with-each-database-in-its-own-sql-file/
    mysql -u root -pABCDEF -N -e 'show databases' | while read dbname; do mysqldump -u root -pABCDEF --complete-insert --routines --triggers --single-transaction "$dbname" > "$dbname".sql; done
  • Download and compress
    mysql -u root -pABCDEF -N -e 'show databases' | while read dbname; do mysqldump -u root -pABCDEF --complete-insert --routines --triggers --single-transaction "$dbname" > "$dbname".sql; [[ $? -eq 0 ]] && gzip "$dbname".sql; done
Share

Leave a Reply

Your email address will not be published. Required fields are marked *