1

I have read through many similar questions on SE, but I can not sort out what is werong with my import. SQL does not return an error but 0/200 rows are uploaded. So I have a csv file with about 20x 12 columns. I have tried both with and without headers on the columns. I open mysql on the server and use the suggested import statement:

LOAD DATA INFILE "full_path_to_csv_file.filename.csv"
INTO TABLE users
COLUMNS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"'
ESCAPED BY '"'
LINES TERMINATED BY '\n'
IGNORE 1 LINES;

I have tried both with and without the last line. I have tried removing the auto-increment column. I have all empty fields set to NULL...

.. and there are no errors, but 0 rows are uploaded.

I can't see what I'm doing wrong.

Help.

2
  • Does MySQL have access to the file on the server, or maybe it doesn't have read-access? Personally I prefer to just create an insert script, especially for relatively small files. You could try this plugin, which can convert a csv file to an SQL insert script github.com/BdR76/CSVLint or alternatively there is also this tool to convert to SQL insert script github.com/BdR76/datasetmultitool Commented Sep 14, 2021 at 7:49
  • 1
    Are you sure the lines are terminated by '\n'. If the file comes from a Mac or a Windows machine it would be '\r' or '\r\n' respectively. Take a look at this answer unless you are sure this is a UNIX created file, in which case it should be OK with '\n' stackoverflow.com/questions/4682965/… Commented Sep 14, 2021 at 8:46

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.