MySQL full backup and recovery

Source: Internet
Author: User

Importance of Backup:

    • In the production environment, our database may encounter a variety of accidents resulting in data loss, probably divided into the following several.
    • Hardware failure
    • Software failure
    • Natural disasters
    • xxxxxx
    • Error operation (maximum ratio)
      Backup type:
      Physical and logical angles:
      Physical Backup---Refers to a backup of the physical files of the database operating system
      Logical backup---Refers to a backup of the logical components of a database
      Backup Policy angle:
      Full backup---Back up the entire data set
      Differential backup---Files that have been modified since the last full backup
      Incremental backup---data that has changed since the last backup (incremental or complete)

Physical Backup Walkthroughs
1. Installing the XZ compression format tool

Yum Install-y XZ

2, backup (that is, the database folder/usr/local/mysql/data packaging)

Tar jcvf/opt/mysql-$ (date +%f). tar.xz/usr/local/mysql/data/


3, delete, restore operation (Restore the backup to the database folder can be)

Tar jxvf/opt/mysql-2018-08-30.tar.xz/usr/local/mysql/data/

Logical Backup Walkthrough
The preparatory work is as follows:
(a) First to add a database of non-login operations, after which the demonstration will be displayed in this way;

Mysql-uroot-pabc123-e ' show databases; ' #单条信息输入

Mysql-uroot-pabc123-e ' show databases;use school;show tables; ' #多条信息输入, note the order

(b) The following is the school database created before backup and restore, and the next operations are for the school database

First, a full backup of the database
Method 1: Only the tables are created, recorded, and data must be created in advance of recovery

Backup: mysqldump-uroot-pabc123 School >/opt/school.sql

Recovery: mysql-uroot-pabc123 School </opt/school.sql


Method 2: Add--databases restore without building a library

Backup: mysqldump-uroot-pabc123--databases School >/opt/school.sql

Recovery: mysql-uroot-pabc123 </opt/school1.sql


Method 3:source Statement---must be executed in the MySQL environment

Backup: mysqldump-uroot-pabc123--databases School >/opt/school.sql

Recovery: Mysql>source/opt/school.sql


Second, a full backup of the tables in the database

Backup---mysqldump-uroot-pabc123 school info >/opt/info.sql
Recovery---mysql-uroot-pabc123 School </opt/sinfo.sql


Third, a full backup of the table structure

mysqldump-uroot-pabc123-d School Info >/opt/school.sql #增加-d parameter

Iv. full backup of all libraries

mysqldump-uroot-pabc123--all-databases >/opt/databases.sql

MySQL full backup and recovery

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.