MySQL database backup and restore common commands

Source: Internet
Author: User
Tags format sql mysql mysql database backup

MysqlDatabase backup and restore common commands are the key to MySQL database backup and restore, there is no command, WhatDo not have to do, not to mention what backup restore, only to the system this command, let it to execute, in order to complete the MySQL database backup and restore operations, the following is the operation of the common commands.

One, Backup command

1, backup the MySQL database command

Mysqldump-hhostname-uusername-ppassword Databasename>backupfile.sql

2, backup MySQL database for the format with the deleted table

Backing up the MySQL database is a format with a deleted table that allows the backup to overwrite the existing database without having to manually delete the original database.

Mysqldump-–add-drop-table-uusername-ppassword Databasename>backupfile.sql

3, directly to the MySQL database compression backup

Mysqldump-hhostname-uusername-ppassword databasenamegzip>backupfile.sql.gz

4, Backup MySQL database some (some) table

Mysqldump-hhostname-uusername-ppassword databasename Specific_table1 Specific_table2>backupfile.sql

5. Backup multiple MySQL databases at the same time

Mysqldump-hhostname-uusername-ppassword–databases databasename1 databasename2 databasename3> Multibackupfile.sql

6. Only BACKUP DATABASE structure

Mysqldump–no-data–databases databasename1 databasename2 Databasename3>structurebackupfile.sql

7, backup all databases on the server

Mysqldump–all-databases>allbackupfile.sql

Second, restore command

1, restore the MySQL database command

Mysql-hhostname-uusername-ppassword Databasename

2, restore the compressed MySQL database

Gunzip

3, transfer the database to the new server

Mysqldump-uusername-ppassword databasenamemysql–host=*.*.*.*-c DatabaseName

Summarize:

Do data backup and restore, set appropriate backup strategy, this is a DBA to do a small part of things, the beginning of the difficult, starting from now!



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.