Home > Database > Mysql Tutorial > body text

如何在linux下实现mysql数据库每天自动备份_MySQL

WBOY
Release: 2016-06-01 13:36:33
Original
1202 people have browsed it

bitsCN.com

如何在linux下实现mysql数据库每天自动备份

 

建备份文件夹:

mkdir mysql_data_bak

建脚本文件:

touch autobackupmysql.sh

打开文件

vi  autobackupmysql.sh

在脚本中加入如下内容:

filename=`date +%Y%m%d`

/usr/bin/mysqldump -uroot -proot boss >>/home/mysql_data_bak/$filename.sql

 

检查有没安装crond,如果没有,先安装

yum -y install vixie-cron

yum -y install crontabs

启动服务 :service crond start

在CentOS系统中加入开机自动启动: chkconfig --level 345 crond on

crontab -e

加入内容:00 03 * * * source /root/autobackupmysql.sh  

 

每天凌晨3点运行此文件,对数据库进行备份

 service crond restart

完成

 

bitsCN.com
Related labels:
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!