Home > Database > Mysql Tutorial > mysql备份远程数据库(只适合局域网使用)

mysql备份远程数据库(只适合局域网使用)

WBOY
Release: 2016-06-07 16:38:48
Original
1044 people have browsed it

#! /bin/bash#定义数据库连接、目标库信息MY_USER="user"#mysql用户MY_PASS="pass"#mysql密码MY_HOST="192.168.1.1"#mysql数据库地址MY_CONN="-u $MY_USER -p$MY_PASS -h $MY_HOST"MY_DB1="db"#数据库名称#定义备份目录、工具、时间、文件名主体BF_DIR="/tmp

#! /bin/bash
#定义数据库连接、目标库信息
MY_USER="user"						#mysql用户
MY_PASS="pass"						#mysql密码
MY_HOST="192.168.1.1"					#mysql数据库地址
MY_CONN="-u $MY_USER -p$MY_PASS -h $MY_HOST"		
MY_DB1="db"						#数据库名称
#定义备份目录、工具、时间、文件名主体
BF_DIR="/tmp/dbbak/"					#数据库备份目录
BF_CMD="/etc/mysql/bin/mysqldump"			#mysqldump路径
BF_TIME=`date +%Y%m%d-%H%M`
NAME_1="$MY_DB1-$BF_TIME"
#先导出为.sql脚本,然后再进行压缩
$BF_CMD $MY_CONN --databases $MY_DB1 >$BF_DIR/$NAME_1.sql	#导出sql文件
cd $BF_DIR/
/bin/tar zcf $NAME_1.tar.gz $NAME_1.sql				#压缩sql文件
Copy after login
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template