備份: 語法: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()傳到哪個指定目錄的。