Dump all MySQL databases on a Linux server with a single line of bash

Run this in the folder where you want the files dumped:

for I in $(mysql -uroot -p -e 'show databases' -s --skip-column-names); do mysqldump $I  > "$I.sql"; done


Leave a Reply

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

Markdown is allowed in comments.