Home >Backend Development >PHP Tutorial >请教如何把txt文件导入到mysql里面

请教如何把txt文件导入到mysql里面

WBOY
WBOYOriginal
2016-06-13 10:45:241037browse

请问怎么把txt文件导入到mysql里面
请问怎么把txt文件导入到mysql里面,这个txt文件是从别人网站上导出来的,格式固定,是以空格为分割符的,以下是txt文件部分内容:



order-id order-item-id purchase-date payments-date reporting-date promise-date days-past-promise buyer-email buyer-name buyer-phone-number sku product-name quantity-purchased quantity-shipped quantity-to-ship ship-service-level recipient-name ship-address-1 ship-address-2 ship-address-3 ship-city ship-state ship-postal-code ship-country
503-5296313-1551031 67526054392798 2012-06-19T06:09:33+00:00 2012-06-19T06:09:33+00:00 2012-06-19T06:40:09+00:00 2012-06-21T14:59:59+00:00 3 [email protected] 嫿揷媑岶 09021971453 GV0123-Gevey_Pro-37Sa iPhone4懳墳 SIM儘僢僋夝彍傾僟僾僞 iOS4.21摦嶌妋擣嵪傒 1 0 1 Standard 嫿揷媑岶 恄屗巗悅悈嬫懡暦挰 868-812丂巐恄價儖2F 暫屔導 655-0001 JP
249-8506878-4596622 09004509260622 2012-06-19T12:29:37+00:00 2012-06-19T12:29:37+00:00 2012-06-

------解决方案--------------------
用php吗? 
上面第一行是数据库的字段 下面的是数据 所以根据这个格式读成数组 再拼装成SQL语句 执行...
------解决方案--------------------
先建立表。然后在命令行下执行:
load data local infile “c:/data.txt”
into table tt ; 

记住不要把路径搞错了。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn