0

I tried the following code to load data from text document (file name is test.txt) to MySQL database, but it shows an error:

File 'C:test.txt' not found (Errcode: 2)

The query is:

LOAD DATA LOCAL INFILE 'C:test.txt' INTO TABLE messagebox  fields terminated by ','  LINES TERMINATED BY '\n';
Taz
  • 3,718
  • 2
  • 37
  • 59
user1148952
  • 39
  • 4
  • 11

3 Answers3

3

modify your drive address to C:\\test.txt

LOAD DATA LOCAL INFILE 'C:\\test.txt' 

INTO TABLE 'messagebox'

fields terminated by ',' fields escaped by '\\' LINES TERMINATED BY '\n';
Skyrel
  • 200
  • 3
  • 12
  • I have a question here: Is the last line in the answer for specifying paths or for the content of the txt file? – Solace Apr 22 '14 at 23:55
1

@Skyrel answer is perfect.In addition to that for Ubuntu users, use this command

LOAD DATA LOCAL INFILE '/home/user/test.txt' 
Ankit Saxena
  • 2,309
  • 2
  • 18
  • 20
0

You need a slash in your url

c:\test.txt
Ash Burlaczenko
  • 24,778
  • 15
  • 68
  • 99