Mysqldump database Backup RESTORE statement

Source: Internet
Author: User

The free backup tools currently supported by MySQL are: mysqldump, mysqlhotcopy, and can be backed up with SQL syntax: Backup TABLE or SELECT into outfile, or backup binary log (binlog), It can also be a direct copy of the data file and the associated configuration file. MyISAM tables are stored in the form of files, so they are relatively easy to back up, and several of the above mentioned methods are available. Innodb All tables are stored in the same data file ibdata1 (or multiple files, or separate tablespace files), relatively difficult to backup, the free scheme can be copied data files, backup Binlog, or with mysqldump.

The code is as follows Copy Code


Mysqldump--opt SCHOOL>SCHOOL.BBB

Comments:

Back up the database school to the school.bbb file, school.bbb is a text file, file name to take, open look you will
There are new discoveries.

Commands for backing up the MySQL database

The code is as follows Copy Code

Mysqldump-hhostname-uusername-ppassword databasename > Backupfile.sql

Backing up the MySQL database for a deleted table format

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.

The code is as follows Copy Code

Mysqldump-–add-drop-table-uusername-ppassword databasename > Backupfile.sql

Directly compress MySQL database to backup

The code is as follows Copy Code

Mysqldump-hhostname-uusername-ppassword DatabaseName | gzip > backupfile.sql.gz

Backing up a MySQL database (some) tables

The code is as follows Copy Code

Mysqldump-hhostname-uusername-ppassword databasename specific_table1 specific_table2 > Backupfile.sql

Backup multiple MySQL databases at the same time

The code is as follows Copy Code

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

Just back up the database structure

Mysqldump–no-data–databases databasename1 databasename2 databasename3 > Structurebackupfile.sql Backup
All databases on the server

The code is as follows Copy Code

Mysqldump–all-databases > Allbackupfile.sql

command to restore MySQL database

The code is as follows Copy Code

Mysql-hhostname-uusername-ppassword DatabaseName < Backupfile.sql

Restoring a compressed MySQL database

The code is as follows Copy Code

Gunzip < backupfile.sql.gz | Mysql-uusername-ppassword DatabaseName

Transferring a database to a new server

  code is as follows copy code

Mysqldump- Uusername-ppassword DatabaseName | Mysql–host=*.*.*.*-c databasename

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.