Importing a .CSV file in MySQL from command line.

When you want to import records from a .csv file into a table, follow the steps given below:

[root@localhost]$ mysql -u [username] -p [password]

[root@localhost]$ use [my_database]

[root@localhost]$ LOAD DATA LOCAL INFILE ‘userinfo.csv’ INTO TABLE [table name] FIELDS TERMINATED BY ‘,’ LINES TERMINATED BY ‘\n’;

This should be the same command that get executed on windows command prompt as well.