The following is a short code snippet on how to view which MySQL databases are available for a user, then a command to back them up. This should work on Unix and Linux variants.
To view what databases are available to be backed up, run the following command:
$ mysql -u root -h localhost -p -Bse ‘show databases’
To backup each database, run the following command:
$ mysqldump -u root -h localhost -pmypassword databasename | gzip -9 > faqs-db.sql.gz
Leave a Reply