I have a CSV file with approximately 657,000 records.
I want to insert this to my MySQL database.
<?php
$handle = fopen("tdvddir.csv", "r");
$data = fgetcsv($handle, 1000, ",");
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE)
{
echo "INSERT INTO `tdvddir` VALUES ('', '{$data[0]}', '{$data[1]}', '{$data[2]}', '{$data[3]}', '".addslashes($data[4])."');\n";
}
fclose($handle);
?>
php csv-sql.php > temp.sql
nohup mysql --user=root --database=data --password=password < temp.sql &
Problem is, this is taking way too much time. It's been more than 7 hours and only a little more than half got inserted so far.
I even tried importing a CSV via command-line.
load data local infile 'tdvddir.csv' into table data.tdvddir
fields terminated by ','
enclosed by '"'
lines terminated by '\n'
(col2, col3, col4, col5, col6);
ERROR 1148 (42000): The used command is not allowed with this MySQL version
mysql --version
mysql Ver 14.14 Distrib 5.5.60, for debian-linux-gnu (x86_64) using readline 6.3
This is on my Ubuntu 14.04 laptop and not on any server.