MySQL query results data are exported into the database into fileout and cvs/txt related files

Source: Internet
Author: User
Tags mysql query

Mysql-u User name-p password

Mysql> Use Database

Mysql> SELECT columnid,alias,parentid from ' Cms_column ' WHERE alias like '% home theater% ' OR parentid= ' 144500 ' into outfile '/V Ar/lib/mysql-files/column_rb.xls ';

If the following interface appears:

If there is an error in the red box, it means that your MySQL profile import and export permission is limited, only through the Secure_file_priv path to operate, here my path is/var/lib/mysql-files/

Either modify the MySQL configuration file, release the permissions, or change the path.

No special rules directory path, here I am not so troublesome, directly copy the file to the/var/lib/mysql-files/path to execute the above command to export, as follows:

Mysql> SELECT columnid,alias,parentid from ' Cms_column ' WHERE alias like '% home theater% ' OR parentid= ' 144500 ' into outfile '/V Ar/lib/mysql-files/column_rb.xls ';

You will then see:

This will be a success.

The following describes the local or log on to the server, the. cvs file is imported into the MySQL database corresponding to the table, here I am on the company server operation, prepare the data as follows:

--Anshun (the following 7 lines are a total of one SQL statement)
LOAD DATA INFILE '/VAR/LIB/MYSQL-FILES/BOSS/ORDERINFO-ANSHUN.TSV '--the file to be imported
into TABLE orderinfo field TERMINATED by ' \ t '---according to the TAB \ t can also be a comma, each of the fields are split
Optionally enclosed by ' "' lines terminated by ' \ r \ n '--according to \ r \ n It is a piece of data to be wrapped.
Ignore 1 lines--excluding the first line
(UserID, Permark, Keyno,subkind,pcode,serialno,payway,opcode,ordertime,yxcode,servid,fees,payfees,status,       Isgrppay,discount,patch,company,area); --The fields in parentheses are the tables to import

--Liupanshui
LOAD DATA INFILE '/VAR/LIB/MYSQL-FILES/BOSS/ORDERINFO-LIUPANSHUI.TSV '
Into TABLE orderinfo fields TERMINATED by ' \ t '
Optionally enclosed by ' "' lines terminated by ' \ r \ n '
Ignore 1 lines
(UserID, Permark, Keyno,subkind,pcode,serialno,payway,opcode,ordertime,yxcode,servid,fees,payfees,status, Isgrppay,discount,patch,company,area);

--Tongren
LOAD DATA INFILE '/VAR/LIB/MYSQL-FILES/BOSS/ORDERINFO-TONGREN.TSV '
Into TABLE orderinfo fields TERMINATED by ' \ t '
Optionally enclosed by ' "' lines terminated by ' \ r \ n '
Ignore 1 lines
(UserID, Permark, Keyno,subkind,pcode,serialno,payway,opcode,ordertime,yxcode,servid,fees,payfees,status, Isgrppay,discount,patch,company,area);

--Zunyi
LOAD DATA INFILE '/VAR/LIB/MYSQL-FILES/BOSS/ORDERINFO-ZUNYI.TSV '
Into TABLE orderinfo fields TERMINATED by ' \ t '
Optionally enclosed by ' "' lines terminated by ' \ r \ n '
Ignore 1 lines
(UserID, Permark, Keyno,subkind,pcode,serialno,payway,opcode,ordertime,yxcode,servid,fees,payfees,status, Isgrppay,discount,patch,company,area);

--Guiyang
LOAD DATA INFILE '/VAR/LIB/MYSQL-FILES/BOSS/ORDERINFO-GUIYANG.TSV '
Into TABLE orderinfo fields TERMINATED by ' \ t '
Optionally enclosed by ' "' lines terminated by ' \ r \ n '
Ignore 1 lines
(UserID, Permark, Keyno,subkind,pcode,serialno,payway,opcode,ordertime,yxcode,servid,fees,payfees,status, Isgrppay,discount,patch,company,area);

MySQL query results data are exported into the database into fileout and cvs/txt related files

Related Article

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.