java多线程    Java入门    vsftp    ftp    linux配置    centos    FRP教程    HBase    Html5缓存    webp    zabbix    分布式    neo4j图数据库    

一次性备份mysql全部的数据库

遍历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


This entry was posted in Linux, PHP and tagged . Bookmark the permalink.
月小升QQ 2651044202, 技术交流QQ群 178491360
首发地址:月小升博客https://java-er.com/blog/mysql-all/
无特殊说明,文章均为月小升原创,欢迎转载,转载请注明本文地址,谢谢
您的评论是我写作的动力.

Leave a Reply