#!/bin/bash
BACKUP_DIR=/tmp/db_backup
HOST='127.0.0.1'
USER='root'
PASSWORD='root'
DATABASE='mydb'
for T in `mysql -u $USER --password="$PASSWORD" -h $HOST -N -B -e "show tables from $DATABASE"`;
do
echo "Backing up $T"
mysqldump --skip-comments --compact -u $USER --password="$PASSWORD" -h $HOST $DATABASE $T > $BACKUP_DIR/$T.sql
done;
References :
Export MySQL Database into Separate Files per Table | JamesCoyle.net
沒有留言:
張貼留言