您可以从下载的 csv 文件中自己创建 SQL INSERT 语句。通过正确的“awk”命令将文件传输到文件中并将输出写入文件 - 见下文。比使用该文件作为您的 SQL INSERT 提要。
此命令将创建您需要的 SQL:
$ tail -n+2 spam-ip.com_10-28-2013.csv | awk 'BEGIN { FS = ", " } ; {print "INSERT INTO virt100706_wie.banned_ips (ip,date) VALUES (\"" $2 "\",now());"}' > spam-ip.com_10-28-2013.sql
示例管道输出:
$ tail spam-ip.com_10-28-2013.sql
INSERT INTO virt100706_wie.banned_ips (ip,date) VALUES ("61.191.191.154",now());
INSERT INTO virt100706_wie.banned_ips (ip,date) VALUES ("95.79.195.2",now());
INSERT INTO virt100706_wie.banned_ips (ip,date) VALUES ("194.8.75.54",now());
INSERT INTO virt100706_wie.banned_ips (ip,date) VALUES ("218.247.161.37",now());
INSERT INTO virt100706_wie.banned_ips (ip,date) VALUES ("94.75.193.168",now());
INSERT INTO virt100706_wie.banned_ips (ip,date) VALUES ("94.142.128.220",now());
INSERT INTO virt100706_wie.banned_ips (ip,date) VALUES ("212.157.248.198",now());
INSERT INTO virt100706_wie.banned_ips (ip,date) VALUES ("99.228.96.58",now());
INSERT INTO virt100706_wie.banned_ips (ip,date) VALUES ("92.112.40.145",now());
INSERT INTO virt100706_wie.banned_ips (ip,date) VALUES ("118.35.46.144",now());
$
比类似的东西:
$ mysql -u XXX -p virt100706_wie < spam-ip.com_10-28-2013.sql