lxx22
lxx22

Reputation: 225

How to bulk insert a csv file?

BULK INSERT krissmall
FROM 'C:\Users\Administrator\Downloads\misskrisdata_small.csv'
WITH (FIELDTERMINATOR = ',', ROWTERMINATOR = '\n')

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'BULK INSERT krissmall FROM 'C:\Users\Administrator\Downloads\misskrisdata_small.' at line 1

Can someone please tell me where went wrong? Or some other reasons behind this. I stared at this query for a long time, and looked it up a lot but I cannot find where it is wrong.

Upvotes: 1

Views: 3859

Answers (2)

Kermit
Kermit

Reputation: 34054

You tagged phpmyadmin which leads me to believe that you are trying to execute this query from a remote server (possibly a web host). The remote server can't connect to your local drive. You must import through phpMyAdmin or upload the file you wish to import to a directory that phpMyAdmin can see.

Upvotes: 0

tadman
tadman

Reputation: 211540

I'm curious where you looked up BULK INSERT since that doesn't seem to be supported by MySQL at all. Maybe you're reading MS SQL documentation and confusing the two.

What you want is LOAD DATA INFILE which can parse CSV.

Upvotes: 1

Related Questions