How to set up Mysql automatic daily backup _mysql CentOS system

Source: Internet
Author: User
Tags centos

Objective

We all know that data is a relatively important data, often need to back up, each time manually more trouble. Take a look at this article to see how the CentOS system to set up MySQL daily automatic backup bar.

Steps are as follows

To build a backup folder:

mkdir Mysql_data_bak

To build a script file:

Touch autobackupmysql.sh

Open File

VI autobackupmysql.sh

Add the following in your script:

Filename= ' Date +%y%m%d '
/usr/bin/mysqldump-uroot-proot boss >>/home/mysql_data_bak/$filename. sql

Check if there are no installed Crond, if not, install first

Yum-y Install Vixie-cron
yum-y Install Crontabs

To start the service:service crond start

In the CentOS system, add the boot auto start:chkconfig --level 345 crond on

Crontab-e

Add Content: 00 03 * * * source /root/autobackupmysql.sh

Run this file every 3 o'clock in the morning and back up the database

 Service Crond Restart

Well, that's done.

Summarize

The above is the entire content of this article, I hope the content of this article for everyone's study or work can bring some help, if there is doubt you can message exchange, thank you for the cloud Habitat Community support.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.