1. Detailed explanation of MySQL backup typesFor modern Internet companies, data stored in server databases has gradually become the lifeblood of enterprises and companies, and has a very significant impact on the survival and development of enterprises and companies. In order to ensure the security of database data storage and prevent it from being damaged due to misoperation and force majeure, we usually back up the data in the database. There are many ways to back up a MySQL database. Let's explain these backup methods according to different classification standards: 1. Classification based on the impact of backup on the database 1. Hot Backup. It means backing up the database while it is running and has no impact on the normal operation of the database. (II) Classify by backup files 1. Logical backup. When using logical backup, the backed-up data is usually a .sql file. The backed-up content is readable and is a text file. This method is generally used in scenarios such as database upgrades, migrations, or batch modifications of database tables. This method takes a long time to recover. 3. Classification by backup method 1. Full backup. Refers to a complete backup of the database. 2. MySQL database export(I) mysqldump export data mysqldump is a data backup and export tool that comes with the MySQL database. The tool supports data tables of MyISAM and InnoDB engines. The parameters used for mysqldump backup are as follows: mysqldump -uroot -proot -A >all_database.sql mysqldump -uroot -proot pzz > pzz.sql mysqldump -uroot -proot pzz student > student.sql mysqldump -uroot -proot -d pzz > pzz_table.sql mysqldump -uroot -proot -t pzz > pzz_data.sql The above five commands respectively represent exporting all data in the database, exporting data in the pzz database, exporting all data in the student table in the pzz database, exporting data related to the table structure in the pzz database, and exporting the actual data in the pzz database except the table structure. (II) mysqlhotcopy bare file backupIn databases of MySQL 5.5 and below (the mysqlhotcopy command has been deleted in databases of MySQL 5.7), quick backup can be performed. The backup performed by mysqlhotcopy is essentially a direct physical copy of the database table files, except that a lock is used to lock the database contents during the copy. In addition, the mysqlhotcopy command can only back up data tables of the MyISAM engine. The following are examples of using the mysqlhotcopy command: mysqlhotcopy -u root -p root pzz /root mysqlhotcopy -u root -p root pzz./student/root The above two commands, the first one is to back up the pzz database, and the second one is to back up the student data table in the pzz database. The backup process is as follows: (III) Comparison between mysqldump and mysqlhotcopy 1. mysqldump will back up to .sql files, while mysqlhotcopy uses bare file backup. 3. MySQL database import If we use mysqlhotcopy to back up the database, then when restoring it, we only need to overwrite the original data with the backup data. If you want to restore the .sql file exported by mysqldump, you need to import the MySQL data. There are two ways to import MySQL database. One is to use the "<" symbol to directly import the information in the .sql file into the MySQL database. The second is to use the source command to import data after logging into the database. mysql -uroot -proot < exp.sql Or after logging into the database, execute: source /root/exp.sql SummarizeThis is the end of this article about the detailed explanation of MySQL import and export backup. For more relevant MySQL backup content, please search for previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Two ways to implement HTML to randomly drag content positions
Table of contents 1. MySQL replication related co...
Table of contents Preliminary Notes Problem Repro...
This article describes how to install and configu...
Table of contents introduce 1. Pica 2. Lena.js 3....
This article example shares the specific code of ...
Apache SkyWalking Apache SkyWalking is an applica...
Float is often used in web page layout, but the f...
Table of contents Chain calls A small case Chain ...
1. Introduction After MySQL is started, BufferPoo...
This article is an integrated article on how to c...
With the popularity and maturity of Docker, it ha...
The JD carousel was implemented using pure HTML a...
Database modification or deletion operations may ...
Table of contents Preface 1. Basic Environment 1....
For many domestic advertisers, the creation and ev...