简体   繁体   English

如何将一百万条记录插入mysql数据库?

[英]How to insert a million records into a mysql database?

I have a two tables. 我有两个桌子。

TABLE 1 has id(PRIMARY)|RANK|WEBSITE |ADDRESS
This is filled with a million websites.

TABLE 2 has id(PRIMARY)|tag1|tag2|tag3 ......|tag30

I am generating the tags by scraping for the meta tags and other attributes. 我通过抓取元标记和其他属性来生成标记。

I have no problems populating the database for the first few thousand websites. 对于前几千个网站,我没有问题。 After that, I am not able to populate it. 之后,我将无法填充它。 I guess it timed out. 我想它超时了。

How should I proceed to populate the entire database? 我应如何继续填充整个数据库?

EDIT: 编辑:

I am getting the data by scraping the urls of the websites dynamically 我正在通过动态抓取网站的网址来获取数据

It would be good if you specify error message in your question, output of mysql_error etc (if any). 如果您在问题中指定错误消息,mysql_error的输出等(如果有的话),那将是很好的。

If your script execution is interrupted because of PHP timeout, you may try to set corresponding configuration parameters (see here for php.ini configuration for details, and here for configuration in runtime). 如果你的脚本执行,因为PHP超时而中断,您可以尝试设置相应的配置参数(见这里的php.ini配置的详细信息,并在这里为运行时配置)。

If reconfiguration is not possible, you may store last record ID you updated in file / database table, and continue execution starting from next ID next time you run your PHP script. 如果无法重新配置,则可以将上次更新的记录ID存储在文件/数据库表中,并在下次运行PHP脚本时从下一个ID开始继续执行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM