mysql comand to import straight from csv file

This is tested on Mariadb 10.x on CentOS 7 and working splendid by using mysqlimport.

In this example where are using a db name CSV_Import
A csv file named db.csv

mysqlimport --local --fields-terminated-by='|' --columns='Url,Title,Duration,Thumbnail,Embed,Keywords,Category' -u root -p CSV_Import /root/db.csv

--local = import from a local stored files
--fields-terminated-by='|' = which character is used to divide the different import fields in the csv file, typical dividers is ; , |
--columns='' = used to tell which fields and order data is stored in the csv file. IMPORTANT use comma as divider

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.