MySQL load data from CSV

13 Aug 2020

LOAD DATA INFILE 'example.csv'
INTO TABLE table_name
FIELDS TERMINATED BY ','
ENCLOSDED BY '"'
LINES TERMINATED BY '\n'
IGNORE 1 ROWS;

On the Mac, you may get an error:

The MySQL server is running with the --secure-file-priv option so it cannot execute this statement

You need to create a file: /etc/my.cnf, and put below content in the file:

[mysqld]
secure_file_priv=""

References

Back to top