当前位置:网站首页>Mysql database compressed backup_ Summary of MySQL backup compression and database recovery methods
Mysql database compressed backup_ Summary of MySQL backup compression and database recovery methods
2022-06-25 14:01:00 【Full stack programmer webmaster】
Hello everyone , I meet you again , I'm your friend, Quan Jun .
Generally, we pass mysqldump To backup MySQL data library , And upload to other backup machines . If the database is large , The backup transmission may be slow , So we try to make the backup file smaller .
When writing an automatic backup script , It is better to compress the backup results directly , You can also recover directly from a compressed backup . How to use bzip2 and gzip Compress mysql Backup file .
Backup and use bzip Compress :
The code is as follows
mysqldump | bzip2 > outputfile.sql.bz2
from bzip2 Backup recovery :
The code is as follows
bunzip2 < outputfile.sql.bz2 | mysql < mysql options>
Backup and use gzip Compress :
The code is as follows
mysqldump | gzip > outputfile.sql.gz
from gzip Backup recovery :
gunzip < outputfile.sql.gz | mysql < mysql options>
Supplement this article
Back up the specified database
The code is as follows
mysqldump -h hostname -u username -p databasename > db.sql If the path is not specified explicitly, it is assigned to the user's working directory :C:Documents and SettingsAdministrator
You can specify the backup directory explicitly :
The code is as follows
mysqldump -u root -p mydb -h 192.168.14.204 > D:mydb.sql
explain :
-p After that, you don't need to enter a password , You need to enter the password after clicking the Enter key .
Direct will MySQL Database compression backup
The code is as follows
mysqldump -h hostname -u username -p databasename | gzip > db.sql.gz
explain :
gzip yes linux Compressor under , So in windows It can't be used in the environment .
Backup MySQL A database ( some ) surface
The code is as follows
mysqldump -h hostname -u username -p databasename table1 table2 > db.sql
Backup multiple files at the same time MySQL database
The code is as follows
mysqldump -h hostname -u username -p –databases db1 db2 db3 > dbs.sql
Back up all databases on the server
The code is as follows
mysqldump –all-databases > allbackupfile.sql
test :
The code is as follows
mysqldump –all-databases -u root -p > allbackupfile.sql
Enter password: ******windows You can use Mysql Query Browser Of File–》Open Script To execute the backup script , You can also use the following command to restore directly :
The code is as follows
mysql -h hostname -u username -p databasename < backupfile.sql
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/151705.html Link to the original text :https://javaforall.cn
边栏推荐
- QT memory mapping
- OpenStack学习笔记(一)
- 如何在 2022 年为 Web 应用程序选择技术堆栈
- 阻止深度神经网络过拟合(Mysteries of Neural Networks Part II)
- Go--- route filter
- 分类器与cross entropy loss函数
- Rust, le meilleur choix pour un programmeur de démarrer une entreprise?
- 语法'陷阱'
- Vscode--- format setting configuration
- Deeply understand the mathematics behind deep neural networks (mysteries of neural networks Part I)
猜你喜欢

Replace element - counter use of content (2)

K-line diagram 24 classic diagrams (shadow)

JVM 用工具分析OOM经典案例

112页机器学习-数学基础回顾.pptx

Knowledge of initial C language 2.0

Simple realization of mine sweeping

Nr-arfcn and channel grid, synchronous grid and GSCN

Deeply understand the mathematics behind deep neural networks (mysteries of neural networks Part I)

触觉智能分享-RK3568在金融自助终端的应用

历史上的今天:网易成立;首届消费电子展召开;世界上第一次网络直播
随机推荐
Implementation of a small book system
"Mobile cloud Cup" computing power network application innovation competition is in hot registration!
腾讯云搭建Socks5多IP代理服务器实现游戏单窗口单IP完美搭建教程附带工具「建议收藏」
NR-ARFCN和信道栅格、同步栅格和GSCN
On the compatibility of the disabled attribute of input on the mobile terminal
Beego--- notes
112页机器学习-数学基础回顾.pptx
Leetcode: Sword finger offer II 091 Painting house [2D DP]
Is it safe to open an account with tongdaxin stock?
Settings the PC must be turned on
Table de hachage, conflit de hachage
楼宇自动化专用BACnet网关BL103
Cesium--- figure loading
删库跑路、“投毒”、改协议,开源有哪几大红线千万不能踩?
Rust,程序员创业的最佳选择?
数据库中显示error1822,error1824
Installation and removal of MySQL under Windows
Go--- route filter
leetcode:918. Maximum sum of circular subarray [reverse thinking + maximum subarray sum]
Getting started with numpy Library