Backing up and restoring a database with a MySQL qualifier is more power than a SQL file

Source: Internet
Author: User
Tags definition file size sql mysql split backup

In the second edition of the high performance MySQL, the time comparison between the SQL file and the definition character file in the backup and restore was seen.
Method file size Export time restore time
SQL Dump 727M 102s 600s
Delimited dump 669M 86s 301s

It looks like the export of the qualifier file is nearly 20% faster than the SQL file, and the restore speed is one times faster.

Record and summarize grammar:

Backup: SELECT into outfile

SELECT * from Hx_9enjoy into outfile '/tmp/9enjoy.txt '

By default, the tab splits the field, and the record uses \ n Split. You can customize three parameters.

SELECT * from Hx_9enjoy to outfile '/tmp/9enjoy_hx.txt ' FIELDS terminated by ', ' optionally enclosed by ' ' LINES termin Ated by ' \ n ';
Use, split fields, double quotes to qualify field contents, \ n Split records.

You can also specify record output for certain conditions:

SELECT * FROM Hx_9enjoy WHERE ID < outfile '/tmp/9enjoy_100.txt '

Restore: LOAD DATA INFILE

Default condition:
LOAD DATA INFILE '/tmp/9enjoy.txt ' into TABLE hx_9enjoy

If there is a specified definition, add a description of the qualifier:
LOAD DATA INFILE '/tmp/9enjoy.txt ' into the TABLE Hx_9enjoy FIELDS terminated by ', ' optionally enclosed by ' "' LINES Terminat ED by ' \ n '


Attention Matters
1.mysql must have permission to access the directory where the generated files
2. For security reasons, it is not possible to overwrite existing files, regardless of how the permissions of the file are allocated.
3. You cannot export a compressed file directly.




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.