简体   繁体   English

将数据导入MySQL

[英]Importing data to mysql

I have an excel file which contains 4 columns 我有一个包含4列的Excel文件

Chapter ID int fk
Subject ID int fk
Title varchar(100)
Description mediumtext
Recap mediumtext

The Description and Recap columns contain html syntax. DescriptionRecap列包含html语法。 I am currently exporting this data to CSV and then trying to import it into mySQL. 我目前正在将此数据导出到CSV,然后尝试将其导入到mySQL。 However, I receive an error fraying the "file could not be read" . 但是,我收到一条磨损“无法读取文件”的错误消息。

I am guessing this is because of the , , " , etc, present in the html syntax. Does anyone know how else can the data be imported into mySQL. I do not want to alter the html in in the columns. 我猜这是因为,"等,存在于html语法。有谁知道怎么回事,可以把数据导入到MySQL,我不想改变html在列。

Have you tried the "LOAD DATA INFILE". 您是否尝试过“ LOAD DATA INFILE”。 Look at the doc here: http://dev.mysql.com/doc/refman/5.0/en/load-data.html 在此处查看文档: http : //dev.mysql.com/doc/refman/5.0/en/load-data.html

Example: 例:

LOAD DATA INFILE 'c:/nodes.csv' INTO TABLE friends_of_friends
FIELDS TERMINATED BY ';' ENCLOSED BY '' ESCAPED BY '\\';

The ESCAPED BY '\\\\' defines \\ as the escape character. ESCAPED BY '\\\\'\\定义为转义字符。 There are two backslashes needed because the backslash is also the standard MySQL escape character. 需要两个反斜杠,因为反斜杠也是标准的MySQL转义字符。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM