How to import CSV file into MySQL database using command line interface (CLI)

You can easily import CSV files content into MySQL database using mysql console client. You do not need phpmyadmin or other interfaces anymore.

1. Connect to SQL server with command like this:
[root@server user01]# mysql -u db_user -p -h localhost
Prepare CSV file (with columns separated by Tab symbol in case below)
2. Import data into table
mysql> load data local infile 'file.csv' into table test_table fields terminated by '\t' enclosed by '"' lines terminated by '\n' ;

Even more, you can run mysql client and mysql query from bash command line without going into mysql> :

mysql -u your_database_login -h localhost -p your_database_password -e 'load data local infile "file_for_import.csv" into table table_name fields terminated by "\t" ' DB_name

Table format must be constructed according to import file format