当前位置:网站首页>What is the MySQL backup suffix_ MySQL backup restore
What is the MySQL backup suffix_ MySQL backup restore
2022-07-02 19:21:00 【Full stack programmer webmaster】
Hello everyone , I meet you again , I'm your friend, Quan Jun .
One 、 Backup common operation basic command
1、 Backup command mysqldump Format
Format :mysqldump -h Host name -P port -u user name -p password –database Database name > file name .sql
2、 Backup MySQL The database is in the form of deleted tables
Backup MySQL The database is in the form of deleted tables , The backup can overwrite the existing database without manually deleting the original database .
mysqldump –add-drop-table -u username -p password -database databasename > backupfile.sql
3、 Direct will MySQL Database compression backup
mysqldump -h hostname -u username -p password -database databasename | gzip > backupfile.sql.gz
4、 Backup MySQL A database ( some ) surface
mysqldump -h hostname -u username -p password databasename specific_table1 specific_table2 > backupfile.sql
5、 Backup multiple files at the same time MySQL database
mysqldump -h hostname -u username -p password –databases databasename1 databasename2 databasename3 > multibackupfile.sql
6、 Only back up the database structure
mysqldump –no-data –databases databasename1 databasename2 databasename3 > structurebackupfile.sql
7、 Back up all databases on the server
mysqldump –all-databases > allbackupfile.sql
8、 Restore MySQL Database commands
mysql -h hostname -u username -p password databasename
9、 Restore compressed MySQL database
gunzip
10、 Move the database to the new server
mysqldump -u username -p password databasename | mysql –host=*.*.*.* -C databasename
11、–master-data and –single-transaction
stay mysqldump Use in –master-data=2, Will record binlog Document and position Information about .–single-transaction The isolation level will be set to repeatable-commited
12、 Import database
Commonly used source command , use use Go to a database ,mysql>source d:\test.sql, The following parameters are script files .
13、 see binlog journal
see binlog The log can be used with the command mysqlbinlog binlog Log name |more
14、general_log
General_log Record any operation of the database , see general_log The state and position of can be commanded show variables like “general_log%” , Turn on general_log You can use the command set global general_log=on
Two 、 Incremental backup
A small number of databases can be fully backed up every day , Because it won't take much time , But when the database is large , It is unlikely that a full backup will be performed every day , At this time, you can use incremental backup . The principle of incremental backup is to use mysql Of binlog Records .
1、 First, make a full backup :
mysqldump -h hostname -u test2 -p 123 -P 3310 –single-transaction –master-data=2 test>test.sql At this time, you will get a complete file test.sql
stay sql We will see in the document :
— CHANGE MASTER TO MASTER_LOG_FILE=’bin-log.000002′, MASTER_LOG_POS=107; It means that all changes will be saved to bin-log.000002 In binary .
2、 stay test Library t_student Add two records to the table , And then execute flush logs command . A new binary log file will be generated bin-log.000003,bin-log.000002 Then all changes after the full backup are saved , The operation of adding records is also saved in bin-log.00002 in .
3、 And then test In the library a Add two records to the table , Then delete by mistake t_student Table and a surface .a Add record operations and delete tables a and t_student All operations are recorded in bin-log.000003 in .
3、 ... and 、 recovery
1、 First, import all data
mysql -h hostname -u test2 -p 123 -P 3310
2、 recovery bin-log.000002
mysqlbinlog bin-log.000002 |mysql -h hostname -utest2 -p123 -P3310
3、 Recovery section bin-log.000003
stay general_log Found the time point deleted by mistake , Then the more corresponding time point arrives bin-log.000003 Find the corresponding position spot , You need to restore to the previous one deleted by mistake position spot .
The following parameters can be used to control binlog The range of
–start-position Starting point –stop-position The end point
–start-date Starting time –stop-date End time
After finding the recovery point , You can start to recover .
mysqlbinlog mysql-bin.000003 –stop-position=208 |mysql -h hostname -u test2 -p 123 -P 3310
—- perform sql Other ways of documentation
Get into MySQL Console , Use source Command execution
Mysql>source 【sql Full path name of script file 】 or Mysql>\. 【sql Full path name of script file 】, Example :
source C:\test.sql perhaps \. C:\test.sql
open MySQL Command Line Client, Enter the database password to log in , And then use source Order or \.
— matters needing attention
**window Next , Please do not use PowerShell Export , Otherwise, there may be problems with the file format , Unable to import , Please use CMD Command line execution
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/148609.html Link to the original text :https://javaforall.cn
边栏推荐
- [100 cases of JVM tuning practice] 02 - five cases of virtual machine stack and local method stack tuning
- R language ggplot2 visual Facet: gganimate package is based on Transition_ Time function to create dynamic scatter animation (GIF)
- Preprocessing and preprocessing macros
- Have you stepped on the nine common pits in the e-commerce system?
- Processing strategy of message queue message loss and repeated message sending
- Qpropertyanimation use and toast case list in QT
- Excel finds the same value in a column, deletes the row or replaces it with a blank value
- The mybatieshelperpro tool can be generated to the corresponding project folder if necessary
- ICDE 2023|TKDE Poster Session(CFP)
- MySQL advanced learning summary 7: MySQL data structure - Comparison of hash index, AVL tree, B tree and b+ tree
猜你喜欢
![[100 cases of JVM tuning practice] 01 - introduction of JVM and program counter](/img/c4/3bba96fda92328704c2ddd929dcdf6.png)
[100 cases of JVM tuning practice] 01 - introduction of JVM and program counter

仿京东放大镜效果(pink老师版)

Quanzhi A33 uses mainline u-boot

How performance testing creates business value

Compile oglpg-9th-edition source code with clion

Web2.0的巨头纷纷布局VC,Tiger DAO VC或成抵达Web3捷径

守望先锋世界观架构 ——(一款好的游戏是怎么来的)

拦截器与过滤器的区别

思维意识转变是施工企业数字化转型成败的关键

ICDE 2023|TKDE Poster Session(CFP)
随机推荐
C文件输入操作
Masa framework - DDD design (1)
codeforces每日5题(均1700)-第四天
电脑使用哪个录制视频软件比较好
How can retail enterprises open the second growth curve under the full link digital transformation
IEDA refactor的用法
Binary operation
R language uses Cox of epidisplay package Display function obtains the summary statistical information of Cox regression model (risk rate HR, adjusted risk rate and its confidence interval, P value of
Have you stepped on the nine common pits in the e-commerce system?
【JVM调优实战100例】01——JVM的介绍与程序计数器
拦截器与过滤器的区别
PHP asymmetric encryption method private key and public key encryption and decryption method
Gamefi链游系统开发(NFT链游开发功能)丨NFT链游系统开发(Gamefi链游开发源码)
End-to-End Object Detection with Transformers(DETR)论文阅读与理解
[100 cases of JVM tuning practice] 03 -- four cases of JVM heap tuning
The mybatieshelperpro tool can be generated to the corresponding project folder if necessary
Markdown basic grammar
PHP parser badminton reservation applet development requires online system
ICDE 2023|TKDE Poster Session(CFP)
ORA-01455: converting column overflows integer datatype