How to export and import all MySQL databases at one time?

I want to back up all of my MySQL databases regularly. I have around 50 databases. It’s boring to take all the database backup one by one. Is there any way I can export all the databases with a single command? And later import all of them into my MySQL server.

Export :

You can export all the databases with the following command.

mysqldump -u root -p --all-databases > alldb.sql

You can exclude locked tables just by adding the option --skip-lock-tables

mysqldump -u root -p --all-databases --skip-lock-tables > alldb.sql

Import:

mysql -u root -p < alldb.sql