two posts in a day!!! Anyway this is a small tip on how to upload a CSV file in mysql using the command line.
First you need to enable an option on your mysql while accessing it in the usual way :
mysql -u "myuser" -p"mypass" --local-infile=on
This prevents mysql to raise security errors and let’s you load the file (about security error read this on the mysql documentation ).
Now select the target database:
And then load your file using:
LOAD DATA LOCAL INFILE '/home/user/myfile.csv' INTO TABLE mytable FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n';
Remember that if you create your CSV file in a Windows environment lines are terminated by ‘\r\n’, while in a Unix environment lines are terminated by ‘\n’ .