mysqldump backup and restore MySQL database

Source: Internet
Author: User
Tags create database mysql login

MySQL data backup and recovery we can use MYQL's own tools mysqldump, MySQL to achieve.

MYSQLDUMP supports remote single table backups, single database backups, and all database backups.

= = Backup = =

Note the space, additional parameters please add yourself. If-h-u-p, remote backup needs to specify-H server address

-E indicates export SQL is 20 times times faster than normal inserts for bulk inserts

-H Server Host address

-U Account

-P account password

Single-table backup (back up a table)

The code is as follows Copy Code

MYSQLDUMP-E-u xxx-pxxx database name Table name > save location

Single-database backup (backs up all tables in the specified library)

The code is as follows Copy Code

MySQL dump-e-u xxx-pxxx database name > Save location


All database backups (back up all databases)

The code is as follows Copy Code

MYSQLDUMP-E-u xxx-pxxx--all--database > Save location


= = Restore = =

Note the space, additional parameters please add yourself. If-u-p, remote backup needs to be specified:-H server address


Method One:

The code is as follows Copy Code

Mysql-u Root Database name < location of backup files

Method Two:

You can also use MySQL login to enter the MySQL Shell to execute the following command

Use database name (toggle database)

Source Backup file location (Execute SQL script)

Note: If you do not have a statement in the backup file that drops create database, you will need to manually delete the database after the restore and then create an empty library.

Related Article

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.