Common commands for MySQL database backup and Restoration

Source: Internet
Author: User

The following articles mainly DESCRIBE commands frequently used for backup and restoration of MySQL databases, as well as commands for backing up MySQL databases. The information I saw on the relevant website two days ago is quite good, let's share it with you. I hope you will have some gains.

 
 
  1. mysqldump -hhostname -uusername -ppassword databasename > backupfile.sql 

Back up the MySQL database in the format of a table with deletion

Backing up a MySQL database is in the format of a table with deletion, so that the backup can overwrite existing databases without the need to manually delete the original database.

 
 
  1. mysqldump -–add-drop-table -uusername -ppassword databasename > backupfile.sql 

Directly compress and back up the MySQL database

 
 
  1. mysqldump -hhostname -uusername -ppassword databasename | gzip > backupfile.sql.gz 

Back up a MySQL database table

 
 
  1. mysqldump -hhostname -uusername -ppassword databasename specific_table1 specific_table2 > backupfile.sql 

Back up multiple MySQL databases at the same time

 
 
  1. mysqldump -hhostname -uusername -ppassword –databases databasename1 databasename2 databasename3 > multibackupfile.sql 

Back up database structures only

 
 
  1. mysqldump –no-data –databases databasename1 databasename2 databasename3 > structurebackupfile.sql 

Back up all databases on the server

 
 
  1. mysqldump –all-databases > allbackupfile.sql 

Command for restoring MySQL database

 
 
  1. mysql -hhostname -uusername -ppassword databasename < backupfile.sql 

Restore a compressed MySQL database

 
 
  1. gunzip < backupfile.sql.gz | mysql -uusername -ppassword databasename 

Transfer database to new server

 
 
  1. mysqldump -uusername -ppassword databasename | mysql –host=*.*.*.* -C databasename  

The above content describes the Common commands used for MySQL database backup and restoration. I hope it will help you in this regard.

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.