Dump and restore all MySQL databases in one command

Came across this wonderful discussion on StackOverflow, for dumping all the MySQL databases from command line.

For dumping:

mysqldump -u username -p --all-databases > alldbs.sql

For restoring:

mysql -u username -p < alldbs.sql

The advantage is that it is very quick, and you do not lose the user privileges.

Pratyush Mittal @pratyush