If you want to import the content of a CSV file into a MySQL table then you can follow example below.


CSV file


id,name,surname,
1,inanzzz,hello,
2,welcome,home,

MySQL table


CREATE TABLE `my_imports` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(45) NOT NULL,
`surname` varchar(45) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `id_UNIQUE` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

Import command


mysql> SELECT * FROM my_imports;
Empty set (0.00 sec)

mysql> LOAD DATA LOCAL INFILE '~/Desktop/Untitled.csv'
-> INTO TABLE `my_imports`
-> FIELDS TERMINATED BY ','
-> ENCLOSED BY '"'
-> LINES TERMINATED BY '\n'
-> (`id`, `name`, `surname`);

Query OK, 2 rows affected, 4 warnings (0.01 sec)
Records: 3 Deleted: 0 Skipped: 1 Warnings: 4

mysql> SELECT * FROM my_imports;
+----+---------+---------+
| id | name | surname |
+----+---------+---------+
| 1 | name | surname |
| 2 | welcome | home |
+----+---------+---------+
2 rows in set (0.00 sec)