当前位置:网站首页>Backup method of mysqldump
Backup method of mysqldump
2022-06-24 04:05:00 【User 8989785】
mysqldump yes MySQL The logic backup tool of the system , It is mainly used to dump the database . It mainly produces a series of SQL sentence , Can be encapsulated into a file , This file contains the SQL Orders such as CREATE DATABASE ,CREATE TABLE ,INSERT wait . When we need to restore this data , Just execute this file , The corresponding data can be restored .
mysqldump The basic syntax is as follows :
Usage: mysqldump [OPTIONS] database [tables] OR mysqldump [OPTIONS] --databases [OPTIONS] DB1 [DB2 DB3...] OR mysqldump [OPTIONS] --all-databases [OPTIONS]
perform mysqldump --help Or reference MySQL Official documents , We found that mysqldump There are many parameters that the tool can configure , The following is a brief description of some commonly used parameters .
The table above shows some common mysqldump Related options , When you don't understand what a parameter does , It can be executed mysqldump --help To get help . For boolean type parameters , In general, there is an opposite parameter , Such as --triggers Default on , have access to --skip-triggers To disable it .
A few backup tips
although mysqldump It's not suitable for backup with large amount of data , But because of its flexibility and convenience 、 Parameters can be customized according to the scene , Or is it widely used in the field of data export .
According to my own experience , Let's share a few points mysqldump Backup tips :
- It is recommended to use --single-transaction Parameter to get a consistent backup , Reduce the lock .
- Export on demand , As long as you want the data , Minimize the export file size .
- If you want to build a slave Library , It is recommended to use --master-data = 2 Parameter record main library binlog Information .
- If you want to back up stored procedures 、 Custom functions and events , Please add -R -E Parameters , They are not turned on by default .
- Don't add parameters you don't know , By default .
Let's share a few different scenarios mysqldump Usage method :
# Back up all databases ( Contains stored procedures 、 Custom functions and events ) mysqldump -uroot -pxxxxxx --single-transaction -R -E --all-databases > /tmp/all_database.sql # Record required binlog Site information It can be used to build slave libraries mysqldump -uroot -pxxxxxx --single-transaction -R -E --all-databases --master-data=2 > /tmp/all_database.sql # Back up the specified database mysqldump -uroot -pxxxxxx --single-transaction -R -E --databases db1 > /tmp/db1.sql mysqldump -uroot -pxxxxxx --single-transaction -R -E --databases db1 db2 > /tmp/db1_db2.sql # Back up some tables mysqldump -uroot -pxxxxxx --single-transaction db1 tb1 > /tmp/tb1.sql mysqldump -uroot -pxxxxxx --single-transaction db1 tb1 tb2 tb3 > /tmp/tb.sql # Export a table , The data is in a single line insert Show mysqldump -uroot -pxxxxxx --single-transaction --skip-extended-insert db1 tb1 > /tmp/tb1.sql # Export part of the data of a single table mysqldump -uroot -pxxxxxx --single-transaction db1 tb1 --where=" create_time >= '2021-06-01 00:00:00' " > /tmp/tb1.sql mysqldump -uroot -pxxxxxx --single-transaction db1 tb1 --where='id < 10' > /tmp/tb1.sql # Exclude some table exports mysqldump -uroot -pxxxxxx --single-transaction --databases db1 --ignore-table=db1.tb1 --ignore-table=db1.tb2 > /tmp/db1.sql # Export only structure or data mysqldump -uroot -pxxxxxx db1 --no-data > /tmp/db1_jiegou.sql mysqldump -uroot -pxxxxxx db1 --no-create-info > /tmp/db1_data.sql # Only export stored procedures and custom functions of a library mysqldump -uroot -pxxxxxx -d -t -R db1 > /tmp/db1_routine.sql # Remote export namely MySQL The server is not local mysqldump -uroot -pxxxxxx -hxxx.xxx.xx -P3306 --single-transaction --databases db1 > /tmp/db1.sql
边栏推荐
- [code Capriccio - dynamic planning] t392 Judgement subsequence
- LeetCode 938. Range sum of binary search tree
- 黑帽SEO实战搜索引擎快照劫持
- In the post epidemic era, "cloud live broadcast" saves "cloud cultural tourism"?
- 黑帽SEO实战之目录轮链批量生成百万页面
- How to restore the default route for Tencent cloud single network card machine
- Discussion on the introduction principle and practice of fuzzy testing
- How do websites use CDN? What are the benefits of using it?
- ClickHouse(02)ClickHouse架构设计介绍概述与ClickHouse数据分片设计
- Rasa 3.x 学习系列-Rasa 3.2.0 新版本发布
猜你喜欢

Clang代码覆盖率检测(插桩技术)

Halcon knowledge: contour operator on region (2)

openEuler Kernel 技术分享第 20 期 | 执行实体创建与切换

黑帽SEO实战之通用301权重pr劫持

On game safety (I)

Kubernetes 资源拓扑感知调度优化
![[code Capriccio - dynamic planning] t392 Judgement subsequence](/img/59/9da6d70195ce64b70ada8687a07488.png)
[code Capriccio - dynamic planning] t392 Judgement subsequence

JVM调优简要思想及简单案例-怎么调优

Koom of memory leak

Black hat SEO actual combat directory wheel chain generates millions of pages in batch
随机推荐
C language in DSP (2) -- definition of structure
MySQL cases SQL causes 100% CPU utilization
A problem of testing security group access in windows10
系统的去学习一门编程语言,原来有如此捷径
ModStartCMS 主题入门开发教程
golang clean a slice
Demonstration of C language structure function research
Modstartcms enterprise content site building system (supporting laravel9) v4.2.0
How to restore the default route for Tencent cloud single network card machine
How to do the right thing in digital marketing of consumer goods enterprises?
Can the video streams of devices connected to easygbs from the intranet and the public network go through their respective networks?
Received status code 502 from server: Bad Gateway
hprofStringCache
golang clean a slice
Pine Script脚本常用内容
TCP three handshakes and four waves
C language - number of bytes occupied by structure
An accident caused by a MySQL misoperation, and the "high availability" cannot withstand it!
Web penetration test - 5. Brute force cracking vulnerability - (7) MySQL password cracking
"." in the structure of C language And "- & gt;" Differences between