MySQL uses the delimiter to import and export records and summarizes the Syntax: Backup:
SELECT INTO OUTFILESELECT * FROM hx_9enjoy INTO OUTFILE '/tmp/9enjoy.txt'
By default, fields are separated by tab, and records are separated by \ n. You can customize three parameters.
SELECT * FROM hx_9enjoy INTO OUTFILE '/tmp/9enjoy_hx.txt' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n';
That is, use, split field, double quotation marks limit field content, \ n split record. You can also specify the record output for certain conditions:
SELECT * FROM hx_9enjoy WHERE id < 100 INTO OUTFILE '/tmp/9enjoy_100.txt'
Restore:
LOAD DATA INFILE
Default:
LOAD DATA INFILE '/tmp/9enjoy.txt' INTO TABLE hx_9enjoy
If a Delimiter is specified, the Delimiter is added:
LOAD DATA INFILE '/tmp/9enjoy.txt' INTO TABLE hx_9enjoy FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n'
Note 1. mysql must have the permission to access the directory where the file is generated. 2. For security reasons, the existing file cannot be overwritten, no matter how permissions are assigned to the file. 3. You cannot export a compressed file directly.