Use mysqldump of mysql database for automatic backup _ MySQL

Source: Internet
Author: User
Use mysqldump of the mysql database to implement automatic backup of mysqldump

Mysql database mysqldump can be used for Database Backup. if crontabs is configured in linux, automatic backup can be implemented!

#! /Bin/bash

# Configure the original database connection information, that is, you are using the machine that needs to be backed up.

SOURCE_USER =-uroot

# If the ip address is on the local machine, that is, SOURCE_HOST =-h127.0.0.1

SOURCE_HOST =-h10.10.10.12

SOURCE_PASS =-padministrator

# Configure the connection information of the backup database, that is, the database machine used for backup

BAK_USER =-uroot

# Ip address of the database machine used for backup

BAK_HOST =-h10.10.10.22

BAK_PASS =-padministrator

# Export the database table content from the original database and generate an SQL file. STATION indicates the database name, and username and files indicates the table name.

/Var/mysql/bin/mysqldump -- add-drop-table -- opt $ SOURCE_USER $ SOURCE_HOST $ SOURCE_PASS STATION username>/tmp/username. SQL

/Var/mysql/bin/mysqldump -- add-drop-table -- opt $ SOURCE_USER $ SOURCE_HOST $ SOURCE_PASS STATION files>/tmp/files. SQL

# Import data to the backup database

/Var/mysql/bin/mysql $ BAK_USER $ BAK_HOST $ BAK_PASS STATION

/Var/mysql/bin/mysql $ BAK_USER $ BAK_HOST $ BAK_PASS STATION

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.