Search code examples
mysqlsyntaxload-data-infile

MYSQL LOAD DATA INFILE Syntax Error - where is it wrong?


where is the Synthax error here?

LOAD DATA INFILE 'mysqlout_back.txt' 
INTO TABLE temp (user,category,site,tld,ip,updated,date) 
FIELDS TERMINATED BY '\t' 
LINES TERMINATED BY '\n' ;

Solution

  • If you only want to load the data in specific columns, the go to the end:

    LOAD DATA INFILE 'mysqlout_back.txt' 
    INTO TABLE temp FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n' 
    (user,category,site,tld,ip,updated,date) ;
    

    EDIT, regarding the file location in your comments:

    The server uses the following rules to locate the file:

    • If the file name is an absolute path name, the server uses it as given.
    • If the file name is a relative path name with one or more leading components, the server searches for the file relative to the server's data directory.
    • If a file name with no leading components is given, the server looks for the file in the database directory of the default database.

    See the MySQL ref