MySQL into outfile summary

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.