mysqldump is used to run backups of MySQL databases and it is also available in an containerised format – using Docker.
Docker is becoming an increasingly popular way of packaging and distributing software. With its Docker Hub ecosystem of ready-made images it has never been easier to try new technologies – without installing anything other than Docker on your machine.
The following commands will allow you to backup your MySQL easily and in an instant.
Backup All MySQL Databases
docker run -it mysql:latest /usr/bin/mysqldump -h [MYSQL HOST] -u [MYSQL USERNAME] --password=[MYSQL PASSWORD] -f --all-databases > mysql_all_databases_backup.sql
Backup MySQL Database
docker run -it mysql:latest /usr/bin/mysqldump -h [MYSQL HOST] -u [MYSQL USERNAME] --password=[MYSQL PASSWORD] -f [MYSQL DATABASE NAME] > mysql_database_backup.sql
Backup MySQL Table
docker run -it mysql:latest /usr/bin/mysqldump -h [MYSQL HOST] -u [MYSQL USERNAME] --password=[MYSQL PASSWORD] -f [MYSQL DATABASE NAME] [MYSQL TABLE NAME] > mysql_table_backup.sql
Finally, if you are running your WordPress site on MySQL then you might be interested in Changing MySQL Database Settings in WordPress.