遍历mysql 数据库 有多少表
#!/bin/sh
BIN_DIR="/usr/local/mysql/bin"
DATE=`date +%F`
BCK_DIR="/backup/backupwebsite/mysql/all/$DATE"
mkdir -p $BCK_DIR
DBS=`mysql -Bse "show databases"|grep -v "information_schema" |grep -v "test"`
for DB_NAME in $DBS
do
echo $DB_NAME
done
一次性备份mysql数据库所有表
#!/bin/sh
BIN_DIR="/usr/local/mysql/bin"
DATE=`date +%F`
BCK_DIR="/backup/backupwebsite/mysql/all/$DATE"
mkdir -p $BCK_DIR
DBS=`mysql -Bse "show databases"|grep -v "information_schema" |grep -v "test"`
for DB_NAME in $DBS
do
echo $DB_NAME
$BIN_DIR/mysqldump --default-character-set=utf8 --opt $DB_NAME | gzip > $B
CK_DIR/$DB_NAME.gz
done
带着密码账户的脚本
DBS=`mysql -u$MYUSER -p$MYPASS -Bse "show databases"|grep -v "information_schema" |grep -v "test"`
账户导出单库
mysqldump --default-character-set utf8 -u root --password=111111 --database School > C:\School.sql
mysqldump --default-character-set utf8 -u root --password=111111 School student > C:\School_Student.sql