简体   繁体   中英

mysql LOAD DATA INFILE query problem

I am trying to load a dump file (csv) into mysql.. I am using the following query

LOAD DATA LOCAL INFILE 'filename.csv' INTO TABLE add_to_cart FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' (fields...);

But it only returns me the first row... Why is it not going thru the complete csv file and simply giving me the first row. Thanks.

Try to run the same command from Terminal and share the output.

If you are getting any value in skipped, as given below. Then the issue is in your table.

Query OK, 1 row affected, 65535 warnings (0.53 sec)

Records: 47355 Deleted: 0 Skipped: 4735 Warnings: 68411

Are you sure the csv file has more than one line?

Then, if the csv file does indeed have multiple lines, does the first row in the output table correspond to the first line of the csv file? Or does it somehow happen that the first row of the output table corresponds to the final line of the csv file?

You probably need to change it from

LINES TERMINATED BY '\n'

to

LINES TERMINATED BY '\r\n'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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