MySQL database backup and recovery implementation code

MySQL database backup and recovery implementation code

Database backup

#grammar:
# mysqldump -h server-u username-p password database name> backup file.sql

#Example:
#Single database backup mysqldump -uroot -p123 db1 > db1.sql
mysqldump -uroot -p123 db1 table1 table2 > db1-table1-table2.sql

#Multi-database backup mysqldump -uroot -p123 --databases db1 db2 mysql db3 > db1_db2_mysql_db3.sql

#Backup all librariesmysqldump -uroot -p123 --all-databases > all.sql

Data Recovery

#Method 1:
[root@egon backup]# mysql -uroot -p123 < /backup/all.sql

#Method 2:
mysql> use db1;
mysql> SET SQL_LOG_BIN=0; #Turn off binary logging, only effective for the current session mysql> source /root/db1.sql

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • How to restore data using binlog in mysql5.7
  • MySQL restores data through binlog
  • MySQL uses frm files and ibd files to restore table data
  • MySQL uses binlog logs to implement data recovery
  • Implementation of mysql using mysqlbinlog command to restore accidentally deleted data
  • Two methods of restoring MySQL data
  • MySQL uses mysqldump+binlog to completely restore the deleted database principle analysis
  • Analysis of MySQL data backup and recovery implementation methods
  • MySQL Binlog Data Recovery: Detailed Explanation of Accidentally Deleting a Database
  • Summary of various methods of MySQL data recovery

<<:  Detailed tutorial on docker-compose deployment and configuration of Jenkins

>>:  How to install Nginx in a specified location in Centos system

Recommend

Detailed explanation of the use of Vue h function

Table of contents 1. Understanding 2. Use 1. h() ...

Pure CSS3 to achieve mouse over button animation Part 2

After the previous two chapters, do you have a ne...

Example analysis of interval calculation of mysql date and time

This article uses an example to describe the inte...

Implementing timed page refresh or redirect based on meta

Use meta to implement timed refresh or jump of th...

Implementation and usage scenarios of JS anti-shake throttling function

Table of contents 1. What is Function Anti-shake?...

MySQL fuzzy query statement collection

SQL fuzzy query statement The general fuzzy state...

Nginx high concurrency optimization practice

1. Necessity of Tuning​ I have always been reluct...

Usage of the target attribute of the html tag a

1: If you use the tag <a> to link to a page,...

The concept of MTR in MySQL

MTR stands for Mini-Transaction. As the name sugg...

Implementation of fastdfs+nginx cluster construction

1. Introduction to fastdfs 1. What is fastdfs Fas...

Detailed explanation of three ways to connect Docker containers to each other

There are three ways to interconnect and communic...

JavaScript+html implements random QR code verification on front-end pages

Share the cool front-end page random QR code veri...

MySQL trigger syntax and application examples

This article uses examples to illustrate the synt...

Detailed analysis of the chmod command to modify file permissions under Linux

Use the Linux chmod command to control who can ac...

Modify the maximum number of mysql connections and configuration files in docker

1. Find the mysql image docker ps 2. Enter the mi...