3

I'm trying to load CSV's into a mysql database with this command:

LOAD DATA LOCAL INFILE '\Users\userName\Downloads\tableName.csv' 
INTO TABLE tableName 
FIELDS TERMINATED BY ',' 
LINES TERMINATED BY '\n'

But I recieve this error:

ERROR 2 <HY000>: File 'UsersuserNameDownloadstableName.csv' not found <Errocode: 2 - No such file or directory>

I log onto mysql with the command (as described here MySQL import csv file ERROR 13 (HY000): Can't get stat of /path/file.csv (Errcode: 2)):

mysql -u root -p --local-infile

doing what was described in the link above I was able to import the CSV's on a different MySQL Server (On a seperate machine running Ubuntu). However the same process doesn't seem to be working for a differente MySQL Server instance on a Windows machine using Command Prompt.

asked Jul 14, 2015 at 19:10
3
  • If you're running the command mysql -u root -p --local-infile I assume your MySQL Server is on your local machine, but you said on an Ubuntu machine, can you edit your question and add which one is your client and your server (Ubuntu?). Commented Jul 14, 2015 at 19:21
  • You're not missing 'C:\"? Commented Jul 14, 2015 at 19:24
  • @oNare I added edits hope that clears up any confusion Commented Jul 14, 2015 at 20:27

1 Answer 1

2

Since this is Windows we are dealing with, either use the double backslash

LOAD DATA LOCAL INFILE 'C:\\Users\\userName\\Downloads\\tableName.csv' 
INTO TABLE tableName 
FIELDS TERMINATED BY ',' 
LINES TERMINATED BY '\n'

or the forward slash

LOAD DATA LOCAL INFILE 'C:/Users/userName/Downloads/tableName.csv' 
INTO TABLE tableName 
FIELDS TERMINATED BY ',' 
LINES TERMINATED BY '\n'

It says so in the MySQL Documentation on LOAD DATA INFILE

The file name must be given as a literal string. On Windows, specify backslashes in path names as forward slashes or doubled backslashes. The character_set_filesystem system variable controls the interpretation of the file name.

answered Jul 14, 2015 at 19:40

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.