温馨提醒

如果文章内容或图片资源失效,请留言反馈,我们会及时处理,谢谢

本文最后更新于2023年11月19日,已超过 180天没有更新

报错信息:

Duplicate entry '3261' for key 'PRIMARY'insert into ***_ecms_news_index(classid,checked,newstime,truetime,lastdotime,havehtml) values('1','1','1446087639','1446087687','1446087687','1');

这种帝国CMS报错是因为ecms_news_index索引数字不对,索引ID“3261”的信息已经存在,后添加的信息索引ID必须大于“3261”才行。

照成这种错误一般是后台丢失数据,导致索引无法正常递增混乱。

方法1:后台修复数据库

如果进的了后台尝试后台修复数据库,点击 后台 系统 备份与恢复数据 备份数据

拉到最下面 点击修复数据表和优化数据表即可。

方法2:插入一个大于当前索引的信息

如果后台修复没有用,那我们就来手动或SQL插入一个大于“3261”等等信息,让索引ID重新递增。

手动操作直接参考数据库的信息,ID填一个大于“3261”的即可。

SQL插入下面代码:

INSERT INTO `phome_ecms_news` VALUES (3262, 1, 1, '', '', '', 1, 'admin', '', 1, 0, 1333244472, 0, 1, 0, 0, ',b|', '', '1', 0, 0, 0, 0, 0, 0, '企业11111', 1333244427, '', 0, 1, 1350716513, 0, 0, 0, 0, '', '企业理念:诚信、专业、高效 星兴财务rn', 0, '1', '', 0, '', 0);

第一个字段“3262”就是索引ID,后面的参考自己的字段调整。

方法3:批量重新生成索引

如果以上都不行,只能用SQL想办法让索引ID重新生成一遍,建议分条执行,一是避免超时,二是能发现错误

CREATE TABLE [!db.pre!]ecms_newstemp AS(SELECT id,classid,newstime,truetime,lastdotime,havehtml FROM [!db.pre!]ecms_news);
ALTER TABLE `[!db.pre!]ecms_newstemp` ADD COLUMN `checked` tinyint(1) not null DEFAULT 0 AFTER `classid`;
ALTER TABLE `[!db.pre!]ecms_newstemp` add primary key (id);
alter table [!db.pre!]ecms_news_index rename to [!db.pre!]ecms_news_indexbak;
alter table [!db.pre!]ecms_newstemp rename to [!db.pre!]ecms_news_index;
ALTERTABLE`[!db.pre!]ecms_news_index`CHANGE`id``id`INT(10)NOTNULLAUTO_INCREMENT;
alter table [!db.pre!]ecms_news_index add index(classid);
alter table [!db.pre!]ecms_news_index add index(checked);
alter table [!db.pre!]ecms_news_index add index(newstime);
alter table [!db.pre!]ecms_news_index add index(truetime);
update [!db.pre!]ecms_news_index set checked=1;
历史上的今天
11月
19
    抱歉,历史上的今天作者很懒,什么都没写!
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。