Script - MySQL Dump Databases Separated by DB Name
#!/bin/bash
DUMP_EXEC="mysqldump" #path to mysqldump
MYSQL_EXEC="mysql" #path to mysql
MYSQL_USER="root" #db user
MYSQL_PASSWORD="" #db password
databases="$MYSQL_EXEC -u$MYSQL_USER"
if [ "$MYSQL_PASSWORD" ]; then
databases="$databases -p$MYSQL_PASSWORD"
fi
eval $databases -e 'show databases' | while read dbname
do
if [ "$dbname" ]; then
echo "Dumping database: $dbname"
dumpScript="$DUMP_EXEC --max_allowed_packet=1G -u$MYSQL_USER"
if [ "$MYSQL_PASSWORD" ]; then
dumpScript="$dumpScript -p$MYSQL_PASSWORD"
fi
eval "$dumpScript --complete-insert '$dbname' > '$dbname.sql'"
fi
done