Description:
In a production environment, the security of data is critical, and any loss of data can have serious consequences. Therefore, it is important to back up data and restore data. Here are some things to do with backup and restore of data.
.
.
Lab Environment: A CENTOS7 virtual machine with MySQL database
.
.
The experimental steps are as follows:
.
.
1. In the database, a school database and an info table are added first, and the data in the table is edited by itself.
.
.
2.
Mysqldump-u Root-p School >/opt/school.sql# Generate a backup file under Opt. The database for this backup needs to recreate a new database when it is restored
Mysql-u Root-p School </opt/school.sql #导回数据库 '
.
.
3.
Mysqldump-u root-p--databases School >/opt/school02.sql# Full backup Database. A full backup is not that troublesome and can be directly directed back
Mysql-u Root-p </opt/school02.sql# homing database
.
.
4. You can also back up two databases at the same time to generate a file, back and the same as the original
Mysqldump-u root-p--databases School mysql >/opt/school-mysql.sql# simultaneously back up school with MySQL database
Mysql-u Root-p </opt/school-mysql.sql# homing Database
.
.
5.
Mysqldump-u Root-p School Info >/opt/info.sql# Preparation Data Sheet
Mysql-u Root-p School </opt/info.sql #导回数据表
.
.
6.
Mysqldump-u Root-p-D School Info >/opt/info02.sql# Backup table structure
Mysql-u Root-p School </opt/info02.sql #导回表结构
.
.
7. You can view the backup file under OPT, the red one does not count
.
.
MySQL database backup and restore