I’ve wasted abit of time doing this today…
1. Create your database
>mysqladmin create dbname
2. Create your table with the right fields. (I usually use an Admin tool like phpmyadmin to do this).
3. You need to login to your mysql console
>mysql -u root >use dbname; >LOAD DATA LOCAL INFILE 'path_to_my_file.csv' INTO TABLE tablename FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n' OPTIONALLY ENCLOSED BY """" (field1,field2,field3);
4. Play around with the TERMINATED BY setting and OPTIONAL setting for your own need.