MySQL Dump All Databases and Create (or Recreate) them on Import?

Export: mysqldump -u root -p --all-databases > all_dbs.sql
Import: mysql -u root -p < all_dbs.sql

Export:

mysqldump -uroot -p --all-databases > alldb.sql

Look up the documentation for mysqldump. You may want to use some of the options mentioned in comments:

mysqldump -uroot -p --opt --all-databases > alldb.sql
mysqldump -uroot -p --all-databases --skip-lock-tables> alldb.sql

Import:

mysql -u root -p < alldb.sql

I Just found a new solution:

Create a bash script. It backs up each database into a different file

#!/bin/bash

USER="zend"
PASSWORD=""
#OUTPUT="/Users/rabino/DBs"

#rm "$OUTPUTDIR/*gz" > /dev/null 2>&1

databases=`mysql -u $USER -p$PASSWORD -e "SHOW DATABASES;" | tr -d "| " | grep -v Database`

for db in $databases; do
    if [[ "$db" != "information_schema" ]] && [[ "$db" != "performance_schema" ]] && [[ "$db" != "mysql" ]] && [[ "$db" != _* ]] ; then
        echo "Dumping database: $db"
        mysqldump -u $USER -p$PASSWORD --databases $db > `date +%Y%m%d`.$db.sql
       # gzip $OUTPUT/`date +%Y%m%d`.$db.sql
    fi
done