Backup syntax:
SELECT * FROM table name where condition into outfile '/tmp/table name. txt ';
#注意保存位置 the permissions of/tmp;
#注意备份文件的格式;
Recovery syntax:
Load Data infile ' table name '. ' Into table name;
#注意恢复时备份文件的位置要存放在mysql the database data library directory;
Example : retrieving data based on a time field:
Backup outfile:
SELECT * from PageView where Actiontime >= ' 2015-01-01 00:00 ' and Actiontime <= ' 2015-01-01 23:59 ' into outfile '/ Tmp/pageview7.txt ';
#注意时间的字段; Desc view Time field;
Recover Load Data infile:
Load data infile ' PageView7.txt ' into table PageView;
Use the SELECT * into OUTFILE backup:
SELECT * into OUTFILE '/tmp/xx.txt ' Fields TERMINATED by ', ' optionally-enclosed by ' "' LINES TERMINATED by ' \ n ' from table name ;
Fields TERMINATED by', 'Inter-field separator
Optionally enclosed by' "'enclosing a field is not valid for a numeric type
LINES TERMINATED by' \ n 'Line break
Using the LOAD DATA INFILE Recovery:
LOAD DATA INFILE '/tmp/xx.txt ' into TABLE test. FII fields TERMINATED by ', ' optionally enclosed by ' "' LINES TERMINATED by ' \ n ';
Reference Links:
Http://blog.chinaunix.net/uid-24373487-id-3191050.html
Http://www.cnblogs.com/stublue/archive/2012/07/02/2573860.html
Mysqldump Backup Reference Link:
http://linuxboys.blog.51cto.com/9150052/1579346
This article from "thinking More than technology" blog, declined reprint!
MySQL into outfile summary