magento SQLSTATE [23000]:完整性约束违规:1062重复条目'363624'用于键'PRIMARY'

时间:2021-06-22 07:36:04

i have migrated a mgento installation doing the following:

我已经迁移了一个mgento安装,执行以下操作:

  1. copied all files
  2. 复制了所有文件

  3. exported the db
  4. 导出数据库

  5. imported the db using mysql workbench
  6. 使用mysql workbench导入数据库

  7. changed the base_url's to the new domain
  8. 将base_url更改为新域

  9. updated local.xml to the correct settings
  10. 将local.xml更新为正确的设置

now im getting:

现在我得到:

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '363624' for key 'PRIMARY'

I have searched the db for this key 363624 , but it is not duplicated as the messages says

我在数据库中搜索了这个密钥363624,但它没有重复,因为消息说

how can i solve this ?

我怎么能解决这个问题?

6 个解决方案

#1


8  

It is not duplicated but rather something must be trying to duplicate it.

它不是重复的,而是必须尝试复制它。

How did you export the database? I would check that the dumped SQL file has the line "SET FOREIGN_KEY_CHECKS=0;" or similar at the top.

你是如何导出数据库的?我会检查转储的SQL文件是否有“SET FOREIGN_KEY_CHECKS = 0;”或类似的顶部。

If not, I would drop the database and add this line to the top of the file:

如果没有,我会删除数据库并将此行添加到文件的顶部:

SET FOREIGN_KEY_CHECKS=0;

... and this line to the bottom:

......这条线到底部:

SET FOREIGN_KEY_CHECKS=1;

... then try again.

...然后再试一次。

#2


28  

This helped me (clearing some of the tables):

这有助于我(清除一些表格):

Enter your Magento database and run following sql query:

输入您的Magento数据库并运行以下sql查询:

TRUNCATE dataflow_batch_export ; 
TRUNCATE dataflow_batch_import ; 
TRUNCATE log_customer ; 
TRUNCATE log_quote ; 
TRUNCATE log_summary ; 
TRUNCATE log_summary_type ; 
TRUNCATE log_url ; 
TRUNCATE log_url_info ; 
TRUNCATE log_visitor ; 
TRUNCATE log_visitor_info ; 
TRUNCATE log_visitor_online ; 
TRUNCATE report_event ;

#3


5  

I was getting the same error.

我得到了同样的错误。

For me, it turns out that the export was taking so long with the site staying 'live' that the end of the export was out of sync with the beginning.

对我而言,事实证明,出口花费了很长时间,网站保持“现场”状态,导致出口结束与开始时不同步。

Specifically, the 'log_visitor_info' table had about 100 more records than some of the other related visitor log tables, so the DB is trying to create a record ID from another table that already exists here.

具体来说,'log_visitor_info'表比其他一些相关的访问者日志表有大约100个记录,因此DB正在尝试从此处已存在的另一个表创建记录ID。

I just deleted the last 100 or so records from this specific table and things worked again without the error. Alternatively it looks like you can mash on the f5 key until you increment past that already-existing ID and Magento will start working again.

我刚刚从这个特定的表中删除了最后100条左右的记录,并且事情再次起作用而没有错误。或者看起来你可以在f5键上进行混搭,直到你超过已经存在的ID并且Magento将再次开始工作。

I suspect that putting the store in maintenance mode before the export may help with this particular error.

我怀疑在导出之前将商店置于维护模式可能有助于解决此特定错误。

#4


0  

In my case the problem was UTF-8 without BOM encoding in text editor. I've change to UTF-8 with BOM and everything works fine.

就我而言,问题是在文本编辑器中没有BOM编码的UTF-8。我用BOM改为UTF-8,一切正常。

#5


0  

if the error showing for the table 'cataloginventory_stock_item' having 'UNQ_CATALOGINVENTORY_STOCK_ITEM_PRODUCT_ID_STOCK_ID' index,

如果显示表'cataloginventory_stock_item'的错误有'UNQ_CATALOGINVENTORY_STOCK_ITEM_PRODUCT_ID_STOCK_ID'索引,

then please sure that you are passing different product SKU from your script.

那么请确保您从脚本中传递了不同的产品SKU。

#6


0  

Run this sql query in your magento data base.

在magento数据库中运行此sql查询。

TRUNCATE dataflow_batch_export ;

TRUNCATE dataflow_batch_import ; 

TRUNCATE log_customer ; 

TRUNCATE log_quote ; 

TRUNCATE log_summary ; 

TRUNCATE log_summary_type ; 

TRUNCATE log_url ; 

TRUNCATE log_url_info ; 

TRUNCATE log_visitor ; 

TRUNCATE log_visitor_info ; 

TRUNCATE log_visitor_online ; 

TRUNCATE report_event ;

First you have to check the 'log_visitor_info' table structure. In this table 'visitor_id' field is should default value as null. If default value is set as anything you should run this below query, Otherwise you leave it the below query just execute the above query.

首先,您必须检查'log_visitor_info'表结构。在此表中,“visitor_id”字段的默认值应为null。如果默认值设置为任何你应该运行以下查询,否则你留下以下查询只需执行上述查询。

ALTER TABLE `log_visitor_info` CHANGE `visitor_id` `visitor_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'Visitor ID';

#1


8  

It is not duplicated but rather something must be trying to duplicate it.

它不是重复的,而是必须尝试复制它。

How did you export the database? I would check that the dumped SQL file has the line "SET FOREIGN_KEY_CHECKS=0;" or similar at the top.

你是如何导出数据库的?我会检查转储的SQL文件是否有“SET FOREIGN_KEY_CHECKS = 0;”或类似的顶部。

If not, I would drop the database and add this line to the top of the file:

如果没有,我会删除数据库并将此行添加到文件的顶部:

SET FOREIGN_KEY_CHECKS=0;

... and this line to the bottom:

......这条线到底部:

SET FOREIGN_KEY_CHECKS=1;

... then try again.

...然后再试一次。

#2


28  

This helped me (clearing some of the tables):

这有助于我(清除一些表格):

Enter your Magento database and run following sql query:

输入您的Magento数据库并运行以下sql查询:

TRUNCATE dataflow_batch_export ; 
TRUNCATE dataflow_batch_import ; 
TRUNCATE log_customer ; 
TRUNCATE log_quote ; 
TRUNCATE log_summary ; 
TRUNCATE log_summary_type ; 
TRUNCATE log_url ; 
TRUNCATE log_url_info ; 
TRUNCATE log_visitor ; 
TRUNCATE log_visitor_info ; 
TRUNCATE log_visitor_online ; 
TRUNCATE report_event ;

#3


5  

I was getting the same error.

我得到了同样的错误。

For me, it turns out that the export was taking so long with the site staying 'live' that the end of the export was out of sync with the beginning.

对我而言,事实证明,出口花费了很长时间,网站保持“现场”状态,导致出口结束与开始时不同步。

Specifically, the 'log_visitor_info' table had about 100 more records than some of the other related visitor log tables, so the DB is trying to create a record ID from another table that already exists here.

具体来说,'log_visitor_info'表比其他一些相关的访问者日志表有大约100个记录,因此DB正在尝试从此处已存在的另一个表创建记录ID。

I just deleted the last 100 or so records from this specific table and things worked again without the error. Alternatively it looks like you can mash on the f5 key until you increment past that already-existing ID and Magento will start working again.

我刚刚从这个特定的表中删除了最后100条左右的记录,并且事情再次起作用而没有错误。或者看起来你可以在f5键上进行混搭,直到你超过已经存在的ID并且Magento将再次开始工作。

I suspect that putting the store in maintenance mode before the export may help with this particular error.

我怀疑在导出之前将商店置于维护模式可能有助于解决此特定错误。

#4


0  

In my case the problem was UTF-8 without BOM encoding in text editor. I've change to UTF-8 with BOM and everything works fine.

就我而言,问题是在文本编辑器中没有BOM编码的UTF-8。我用BOM改为UTF-8,一切正常。

#5


0  

if the error showing for the table 'cataloginventory_stock_item' having 'UNQ_CATALOGINVENTORY_STOCK_ITEM_PRODUCT_ID_STOCK_ID' index,

如果显示表'cataloginventory_stock_item'的错误有'UNQ_CATALOGINVENTORY_STOCK_ITEM_PRODUCT_ID_STOCK_ID'索引,

then please sure that you are passing different product SKU from your script.

那么请确保您从脚本中传递了不同的产品SKU。

#6


0  

Run this sql query in your magento data base.

在magento数据库中运行此sql查询。

TRUNCATE dataflow_batch_export ;

TRUNCATE dataflow_batch_import ; 

TRUNCATE log_customer ; 

TRUNCATE log_quote ; 

TRUNCATE log_summary ; 

TRUNCATE log_summary_type ; 

TRUNCATE log_url ; 

TRUNCATE log_url_info ; 

TRUNCATE log_visitor ; 

TRUNCATE log_visitor_info ; 

TRUNCATE log_visitor_online ; 

TRUNCATE report_event ;

First you have to check the 'log_visitor_info' table structure. In this table 'visitor_id' field is should default value as null. If default value is set as anything you should run this below query, Otherwise you leave it the below query just execute the above query.

首先,您必须检查'log_visitor_info'表结构。在此表中,“visitor_id”字段的默认值应为null。如果默认值设置为任何你应该运行以下查询,否则你留下以下查询只需执行上述查询。

ALTER TABLE `log_visitor_info` CHANGE `visitor_id` `visitor_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'Visitor ID';