MySQL Data backup and restore

Source: Internet
Author: User

First, backup

1. Back up a database

-U username-p dbname table1 table2 ... > backupname.sql

Example:
Mysqldump-u root-p owncloud > Owncloud.sql Where: The dbname parameter represents the name of the database, the Table1 and table2 parameters represent the name of the table that needs to be backed up, the entire database is empty, and the Backupname.sql parameter table designs The name of the backup file, preceded by an absolute path. Typically the database is partitioned into a file with a suffix called SQL;

2. Backing up multiple databases

-U username-p--databases dbname2 dbname2 > backup.sql   #加上了--databases option, followed by multiple databases
-u root-p--databases owncloud mysql > backup.sql
-U username-p-all-databases > backupname.sql
-u-root-p-all-databases > All.sql
Second, data restoration
-U root-p [dbname]<-u root-p < backup.sql
Restore a backup of a direct copy directory: When restoring in this way, you must ensure that the version number of the two MySQL databases is the same. Tables of the MyISAM type are valid, and table spaces for InnoDB tables cannot be copied directly for tables that have INNODB types that are not available.  

  

MySQL Data 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.