MySQL database backup and restore

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.