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.

  • 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?). – oNare Jul 14 '15 at 19:21
  • You're not missing 'C:\"? – Vérace Jul 14 '15 at 19:24
  • @oNare I added edits hope that clears up any confusion – TCulos Jul 14 '15 at 20:27
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.