备份mysql数据库
#! /bin/bash
BPATH=/home/backup/mysql_bak
USER="root"
PASSWD="123456"
HOST="192.168.1.5"
DATE=$(date +%Y-%d-%m)
if [ ! -d "$BPATH" ];then
mkdir -p $BPATH
fi
DB=$(mysql -u $USER -h $HOST -p $PASSWD -Bse 'show databases')
for database in $DB
do
if [ ! $database == "information_schema" ;
mysqldump -u $USER -h $HOST -P $PASSWD $database |bzip2> "$BPATH/${DATE}_mysql.gz"
fi
done
导入数据库
#! /bin/bash
BPATH=/home/backup/mysql_bak
USER="root"
PASSWD="123456"
HOST="192.168.1.5"
cd $BPATH
tar zxf all_mysql.tar.gz
mysqldump -u $USER -h $HOST -P $PASSWD < mysql.sql
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。