一次性备份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


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

Leave a Reply

Your email address will not be published. Required fields are marked *

*

*

  

  

About Me

静水流深,水滴石穿