我有一个CSV文件,大约有657000条记录。
<?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 &
问题是,这花费了太多的时间。已经7个多小时了,到目前为止只插入了略多于一半的内容。
我甚至尝试通过
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——版本
mysql Ver 14.14 Distrib 5.5.60, for debian-linux-gnu (x86_64) using readline 6.3