MySQL full backup and quick recovery methods

MySQL full backup and quick recovery methods

A simple MySQL full backup script that backs up the data for the last 15 days.

Backup

#Back up the mysql database every day (save the data script for the last 15 days)

DATE=$(date +%Y%m%d)

/home/cuixiaohuan/lamp/mysql5/bin/mysqldump -uuser -ppassword need_db > /home/cuixiaohuan/bak_sql/mysql_dbxx_$DATE.sql;

find /home/cuixiaohuan/bak_sql/ -mtime +15 -name '*.sql' -exec rm -rf {} \;

recover

mysql data import

drop databases need_db;

create databases need_db;

Import data: Encoding must be set for recovery

./mysql -uroot -p --default-character-set=utf8 need_db < xx.sql

Knowledge point expansion:

Backup and restore using mysqldump

1. Backup principle

The backup principle of mysqldump is relatively simple. First, find out the table structure that needs to be backed up and generate a create statement in a text file; then convert all data records in the table into an insert statement; these statements can be used to create a table and insert data.

2. Back up a database

Basic syntax:

>>> mysqldump -u username -p dbname table1 table2 ... > BackupName.sql

Example description:

mysqldump -u root -p test person > /tmp/backup.sql

3. Back up multiple databases

Basic syntax:

mysqldump -u username -p --databases dbname2 dbname2 > BackupName.sql

Example description:

mysqldump -u root -p --databases test mysql > /tmp/backup.sql

4. Back up all databases

Basic syntax:

mysqldump -u username -p -all-databases > BackupName.sql

Example description:

mysqldump -u -root -p -all-databases > /tmp/all.sql

5. Data Recovery

Basic syntax:

mysql -u root -p [dbname] < backup.sql

Example description:

mysql -u root -p < /tmp/backup.sql

The above is the detailed content of the method of MySQL full backup and quick recovery. For more information about MySQL simple full backup and quick recovery methods, please pay attention to other related articles on 123WORDPRESS.COM!

You may also be interested in:
  • Detailed steps for configuring mysql8.0.20 with binlog2sql and simple backup and recovery
  • A brief analysis of MySQL backup and recovery
  • Detailed explanation of mysql backup and recovery
  • MySQL database backup and recovery implementation code
  • Analysis of MySQL data backup and recovery implementation methods
  • Shell script to implement mysql scheduled backup, deletion and recovery functions
  • How to restore a database and a table from a MySQL full database backup
  • How to restore single table data using MySQL full database backup data
  • MySQL incremental backup and breakpoint recovery script example
  • C# implements MySQL command line backup and recovery
  • MySQL backup and recovery design ideas

<<:  Detailed explanation of the differences between var, let and const in JavaScript es6

>>:  Detailed tutorial on how to connect to a remote server Docker to deploy a Spring Boot project in IDEA

Recommend

mysql trigger creation and usage examples

Table of contents What is a trigger Create a trig...

CSS3 realizes draggable Rubik's Cube 3D effect

Mainly used knowledge points: •css3 3d transforma...

Oracle deployment tutorial in Linux environment

1. Environment and related software Virtual Machi...

MySQL 5.7.17 installation and configuration method graphic tutorial

This article shares the installation and configur...

What are the file attributes of crw, brw, lrw, etc. in Linux?

What is a file? All files are actually a string o...

Detailed steps to install and uninstall Apache (httpd) service on centos 7

uninstall First, confirm whether it has been inst...

Detailed explanation of the command mode in Javascript practice

Table of contents definition structure Examples C...

Introduction and installation of MySQL Shell

Table of contents 01 ReplicaSet Architecture 02 I...

Mysql 5.6.37 winx64 installation dual version mysql notes

If MySQL version 5.0 already exists on the machin...

Two usages of iFrame tags in HTML

I have been working on a project recently - Budou...

Intellij IDEA quick implementation of Docker image deployment method steps

Table of contents 1. Docker enables remote access...

10 content-related principles to improve website performance

<br />English address: http://developer.yaho...