How to import a txt file to mysql

Source: Internet
Author: User
How can I import a txt file to mysql? how can I import a txt file to mysql? the txt file is exported from other websites and the format is fixed, the txt file is separated by spaces. The following is part of the txt File: order-idorder-item-idpurchase-datepaymen. how can I import the txt file to mysql?
How can I import a txt file to mysql? the txt file is exported from other websites and the format is fixed. it is separated by spaces. The following is part of the txt file:



Order-idorder-item-idpurchase-datepayments-datereporting-datepromise-datedays-past-promisebuyer-emailbuyer-namebuyer-phone-numberskuproduct-namequantity-purchasedquantity-shippedquantity-to-shipship-service-levelrecipient-nameship-address-1ship-address-2ship-address-3ship-cityship-stateship-postal-codeship-country
503-5296313-15510da-75260543927982012-06-19t06: 09: 33 + 00: 002012-06-19T06: 09: 33 + 00: 002012-06-19T06: 40: 09 + 00: 002012-06-21T14: 59: 59 + 00: 00340d6s2v8v7pzkct@marketplace.amazon.co.jp 20171000000000000000009021971453gv0123-gevey_pro-37saiphone4 commandid SIM %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% please refer to the following link for more information: 2F please refer to 655-0001JP
249-8506878-4596622090010992606222012-06-19t12: 29: 37 + 00: 002012-06-19T12: 29: 37 + 00: 002012-06-

------ Solution --------------------
Using php?
The first line above is the data under the database field. Therefore, read the data into an array and then assemble the data into an SQL statement for execution...
------ Solution --------------------
Create a table first. Then execute the following command line:
Load data local infile "c:/data.txt"
Into table tt;

Remember not to mistake the path.

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.