How to import CSV file into mysql database using commmand line (terminal)

Import large CSV file using command line rather than using phpMyAdmin or other GUI software. Importing CSV file using command line is much faster, you can import 100000+ rows in seconds which is not possible in phpMyAdmin.

  1. Table name should be same as the CSV file name.
  2. Use this command in your command line.
  3. Please change the field accordingly (username, password, db_name, csv_import.csv)
mysqlimport --ignore-lines=1 --lines-terminated-by='\n' --fields-terminated-by=',' --fields-enclosed-by='"' --verbose --local -uusername -ppassword db_name csv_import.csv

Leave a Reply

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