Importing CSV to MySQL with Load Data Infile

2019-07-26 08:39发布

I'm trying to load a CSV file into MySQL, and I keep getting syntax errors:

load data infile 'c:/worldminwage.csv' fields terminated by ',' enclosed
by '"' lines terminated by '\n' (YearlyWage, PercentGDP, Date
effective);

Can anyone help me get this working? Thanks.

2条回答
聊天终结者
2楼-- · 2019-07-26 08:59

I think This would be more batter

LOAD DATA INFILE 'c:/worldminwage.csv' fields terminated by ',';

Because you will get rid of error like columns numbers are not matching in the .csv file and mysql table

查看更多
干净又极端
3楼-- · 2019-07-26 09:03

Valid syntax is LOAD DATA INFILE 'c:/worldminwage.csv' INTO TABLE tablename.

You forgot to mention which table the data should go in. See LOAD DATA INFILE Syntax

查看更多
登录 后发表回答