备份: 语法:select */字段列表 from 数据源 into outfile 备份文件目标路径 [fields 字段处理] [lines 行处理]; 【备份文件目标路径中文件必须不存在】 fields 字段处理是可选的,是每个字段的数据如何存储,有以下即可小选项 enclosed by:以什么字符来包裹数据,默认是空字符 terminated by :以什么字符作为字段数据结尾,默认是/t,退格符 escaped by: 特殊符号用什么方法处理,默认是"//" optionally enclosed by:以什么字符来包裹数据类型为字符串的数据。 语法: select * from class into outfile "d:/c1.txt" fields enclosed by '-'; select * from class into outfile "d:/c1.txt" fields enclosed by '-' optionally enclosed by "'";
lines 行处理是可选的 starting by :每行以什么开始,默认是空字符串 terminated by :每行记录以什么结束,默认是“/n” 语法: select * from class into outfile "d:/c.txt" lines starting by 'start:'; select * from class into outfile "d:/c1.txt" lines starting by 'start:' terminated by ' /n';
注意:在5.7新增了一个特性,secure_file_priv,它会限制数据的导出,secure-file-priv参数是用来限制LOAD DATA, SELECT ... OUTFILE, and LOAD_FILE()传到哪个指定目录的。