Working with microservices will ramp up the number of MySQL databases. So if you need to create a backup for all of them at once there is a way to do it through the cli. Also importing them at once is achievable as well.
- MySQL database
- root mysql access
Step 1. To export all mysql databases at once run:
mysqldump -u root -p --all-databases > backupalldbs.sql
Step 2. If there are some lock tables you may face issues. So to skip them run:
mysqldump -u root -p --all-databases --skip-lock-tables > backupalldbs.sql
If you need to import all the databases at once run:
mysql -u root -p < backupalldbs.sql
If you have some specific requirements while backing up your MySQL databases don’t hesitate to raise a question in the comments below. If you find this tutorial useful, follow our official channel on telegram.