File per Schema

From Hashmysql
Jump to: navigation, search
#!/bin/bash

if [ "$1" = "" ]; then
   PASSWD=
else
   PASSWD="-p$1"
fi

#
# DB_IGNORE_LIST is for those schemas which we do not want dump the data
#
DB_IGNORE_LIST="information_schema|mysql"
DB_IGNORE_LIST="information_schema"
USER=root
SOCKET="/tmp/mysql.sock"

#
# Really shouldn't need to do much editing below here.
#
DB_LIST=($ mysql -u $USER $PASSWD -S $SOCKET -Be "SHOW DATABASES" --skip-column-names | egrep -v "$DB_IGNORE_LIST" )
for db in $DB_LIST
do
   mysqldump -S $SOCKET -u $USER $PASSWD $db $table> $db.sql
done
Personal tools
Development Guides
Documentation
Installing MySQL
Other Information