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.