mysqlcsverror-codedvd-burning

Error Code: 1193 unknown system variable when importing a CSV


I'm trying to import data from a .csv file and I'm getting and error code 1193 unknown system variable. I'm utilizing MySQL 5.5.34.

LOAD DATA LOCAL INFILE 'path to the file/student_2.csv' 
INTO TABLE STUDENT
FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
IGNORE 2 LINES
(S_ID, S_LAST, S_FIRST, S_MI, S_ADDRESS, S_CITY, S_STATE, S_ZIP, S_PHONE, S_CLASS, @S_DOB, S_PIN, F_ID, @DATE_ENROLLED);
SET S_DOB = STR_TO_DATE(@S_DOB, '%m/%d/%Y'),
DATE_ENROLLED = STR_TO_DATE(@DATE_ENROLLED, '%m/%d/%Y');

The csv file's data is as follows:

S_ID,S_LAST,S_FIRST,S_MI,S_ADDRESS,S_CITY,S_STATE,S_ZIP,S_PHONE,S_CLASS,S_DOB,S_PIN,F_ID,DATE_ENROLLED
Number,String,String,String,String,String,String,String,String,String,Date/Time,String,Number,String
1,Joffs,Tami,R,1817 Eagldge Cle,Houston,TX,74027,356487654,SR,7/14/88,8891,1,1/3/13
2,Petez,Jimmge,C,951 Drainbow Place,Absail,TX,76901,3253945432,SR,18/09/76,1230,1,11/10/02
3,Marks,Johannes,A,1015 Wild St,Dallas,TX,71012,3251454321,JR,08/13/83,1613,1,8/24/03
4,Smyth,Mark,,428 EN 16 Plaza,Arsehole,TX,7012,3221143210,SO,1/14/88,1841,2,8/23/04

I also change the year format from %Y to %y and did not work either. It is something wrong with the script?


Solution

  • Hm - I can't try it out and I did not dive deep into your script, but are you sure about the ; before the set-commands?

        ....
        (S_ID, S_LAST, S_FIRST, S_MI, S_ADDRESS, S_CITY,
         S_STATE, S_ZIP, S_PHONE, S_CLASS, @S_DOB, S_PIN, F_ID, @DATE_ENROLLED);
        SET S_DOB = STR_TO_DATE(@S_DOB, '%m/%d/%Y'),
        DATE_ENROLLED = STR_TO_DATE(@DATE_ENROLLED, '%m/%d/%Y');