2012-02-12 100 views
3

這裏是Synthax錯誤嗎?MYSQL LOAD DATA INFILE語法錯誤 - 它錯在哪裏?

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

什麼是e恐怖消息說? – 2012-02-12 19:30:08

+0

它說在FIELDS TERMINATED BY'\ t'LINES TERMINATED BY'\ n'附近有一個SYNTAX錯誤(6400),但是我不知道應該在哪裏 – user670186 2012-02-12 19:30:51

回答

6

如果你只想要加載特定列中的數據,去到最後:

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

編輯,就在您的意見文件位置:

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.

請參閱MySQL ref

+0

啊謝謝。但現在我得到這個錯誤:錯誤1045(28000):訪問拒絕用戶'concrast'@'%。但是,我已經設置了用戶concrast可以導入數據的權限。現在我必須爲用戶設置全局權限並且它可以工作。但是,現在我得到這個錯誤:無法獲得'[path] /mysqlout_back.txt'(Errcode:13)的統計信息 – user670186 2012-02-12 19:55:04

+0

@ user670186:請參閱我的關於文件位置的編輯。 – konsolenfreddy 2012-02-12 20:00:35

+0

必須將文件複製到數據庫目錄。現在工作,太好了! – user670186 2012-02-12 20:02:27