最近有很多会员都有这类的问题,所以我整理发了出来,希望可以帮到大家。
出现原因1:
通常出现这类 Errno: 1062 的问题都是因为相关的数据表没有把 auto-increcement 属性给添加。(不是每个 Errno: 1062 都是这个原因)
出现问题的例子
SQL: INSERT INTO 0516cdb_posts (fid, tid, first, author, authorid, subject, dateline, message, useip, invisible, usesig, htmlon, bbcodeoff, smileyoff, parseurloff, attachment)
VALUES ('34', '317', '0', '叶子', '3', '', '1137052398', '121212', '58.218.22.136', '0', '1', '0', '-1', '-1', '', '0')
Error: Duplicate entry '17258' for key 1
Errno.: 1062
原因是因为 cdb_posts 的数据表里的属性没有添加 auto-increcement 所导致。
解决方法
- ALTER TABLE `cdb_posts` CHANGE `pid` `pid` INT( 10 ) UNSIGNED NOT NULL AUTO_INCREMENT;
复制代码
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
出现像例子的问题就需要看一看到底是那个数据表没有加上 auto-increcement 。
在例子中的
INSERT INTO 0516cdb_posts (fid, tid, first, author, authorid, subject, dateline, message, useip, invisible, usesig, htmlon, bbcodeoff, smileyoff, parseurloff, attachment)
是 cdb_posts 的没有加上属性没有添加 auto-increcement
如何升级这些数据?
到后台“数据库”里的“数据库升级”,然后把相关的代码贴进,按“提交”。
以下是各类的 auto-increcement 数据表,大家可以根据问题的数据表进行升级。
cdb_ 是默认的表名前缀,如果不同大家可以自行修改。
cdb_adminnotes
- ALTER TABLE `cdb_adminnotes` CHANGE `id` `id` MEDIUMINT(8) UNSIGNED NOT NULL AUTO_INCREMENT;
复制代码
cdb_advertisements
- ALTER TABLE `cdb_advertisements` CHANGE `advid` `advid` MEDIUMINT(8) UNSIGNED NOT NULL AUTO_INCREMENT;
复制代码
cdb_announcements
- ALTER TABLE `cdb_announcements` CHANGE `id` `id` SMALLINT(6) UNSIGNED NOT NULL AUTO_INCREMENT;
复制代码
cdb_attachments
- ALTER TABLE `cdb_attachments` CHANGE `aid` `aid` MEDIUMINT(8) UNSIGNED NOT NULL AUTO_INCREMENT;
复制代码
cdb_attachtypes
- ALTER TABLE `cdb_attachtypes` CHANGE `id` `id` SMALLINT(6) UNSIGNED NOT NULL AUTO_INCREMENT;
复制代码
cdb_banned
- ALTER TABLE `cdb_banned` CHANGE `id` `id` SMALLINT(6) UNSIGNED NOT NULL AUTO_INCREMENT;
复制代码
cdb_bbcodes
- ALTER TABLE `cdb_bbcodes` CHANGE `id` `id` MEDIUMINT(8) UNSIGNED NOT NULL AUTO_INCREMENT;
复制代码
cdb_crons
- ALTER TABLE `cdb_crons` CHANGE `cronid` `cronid` SMALLINT(6) UNSIGNED NOT NULL AUTO_INCREMENT;
复制代码
cdb_forumlinks
- ALTER TABLE `cdb_forumlinks` CHANGE `id` `id` SMALLINT(6) UNSIGNED NOT NULL AUTO_INCREMENT;
复制代码
cdb_forums
- ALTER TABLE `cdb_forums` CHANGE `fid` `fid` SMALLINT(6) UNSIGNED NOT NULL AUTO_INCREMENT;
复制代码
cdb_medals
- ALTER TABLE `cdb_medals` CHANGE `medalid` `medalid` SMALLINT(6) UNSIGNED NOT NULL AUTO_INCREMENT;
复制代码
cdb_members
- ALTER TABLE `cdb_members` CHANGE `uid` `uid` MEDIUMINT(8) UNSIGNED NOT NULL AUTO_INCREMENT;
复制代码
cdb_pluginhooks
- ALTER TABLE `cdb_pluginhooks` CHANGE `pluginhookid` `pluginhookid` MEDIUMINT(8) UNSIGNED NOT NULL AUTO_INCREMENT;
复制代码
cdb_plugins
- ALTER TABLE `cdb_plugins` CHANGE `pluginid` `pluginid` SMALLINT(6) UNSIGNED NOT NULL AUTO_INCREMENT;
复制代码
cdb_pluginvars
- ALTER TABLE `cdb_pluginvars` CHANGE `pluginvarid` `pluginvarid` MEDIUMINT(8) UNSIGNED NOT NULL AUTO_INCREMENT;
复制代码
cdb_pms
- ALTER TABLE `cdb_pms` CHANGE `pmid` `pmid` INT(10) UNSIGNED NOT NULL DEFAULT '0' AUTO_INCREMENT;
复制代码
cdb_pmsearchindex
- ALTER TABLE `cdb_pmsearchindex` CHANGE `searchid` `searchid` INT(10) UNSIGNED NOT NULL DEFAULT '0' AUTO_INCREMENT;
复制代码
cdb_posts
- ALTER TABLE `cdb_posts` CHANGE `pid` `pid` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT;
复制代码
cdb_profilefields
- ALTER TABLE `cdb_profilefields` CHANGE `fieldid` `fieldid` SMALLINT(6) UNSIGNED NOT NULL AUTO_INCREMENT;
复制代码
cdb_ranks
- ALTER TABLE `cdb_ranks` CHANGE `rankid` `rankid` SMALLINT(6) UNSIGNED NOT NULL AUTO_INCREMENT;
复制代码
cdb_searchindex
- ALTER TABLE `cdb_searchindex` CHANGE `searchid` `searchid` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT;
复制代码
cdb_smilies
- ALTER TABLE `cdb_smilies` CHANGE `id` `id` SMALLINT(6) UNSIGNED NOT NULL AUTO_INCREMENT;
复制代码
cdb_styles
- ALTER TABLE `cdb_styles` CHANGE `styleid` `styleid` SMALLINT(6) UNSIGNED NOT NULL AUTO_INCREMENT;
复制代码
cdb_stylevars
- ALTER TABLE `cdb_stylevars` CHANGE `stylevarid` `stylevarid` SMALLINT(6) UNSIGNED NOT NULL AUTO_INCREMENT;
复制代码
cdb_templates
- ALTER TABLE `cdb_templates` CHANGE `templateid` `templateid` SMALLINT(6) UNSIGNED NOT NULL AUTO_INCREMENT;
复制代码
cdb_threads
- ALTER TABLE `cdb_threads` CHANGE `tid` `tid` MEDIUMINT(8) UNSIGNED NOT NULL AUTO_INCREMENT;
复制代码
cdb_threadtypes
- ALTER TABLE `cdb_threadtypes` CHANGE `typeid` `typeid` SMALLINT(6) UNSIGNED NOT NULL AUTO_INCREMENT;
复制代码
cdb_usergroups
- ALTER TABLE `cdb_usergroups` CHANGE `groupid` `groupid` SMALLINT(6) UNSIGNED NOT NULL AUTO_INCREMENT;
复制代码
cdb_words
- ALTER TABLE `cdb_words` CHANGE `id` `id` SMALLINT(6) UNSIGNED NOT NULL AUTO_INCREMENT;
复制代码
================================
出现原因2:
数据重复所造成的.
用username_check将重复用户名处理掉(https://discuz.dismall.com/attachment.php?aid=29112)
https://discuz.dismall.com/viewthread.php?tid=217574
[ 本帖最后由 asdf1999 于 2006-7-6 16:19 编辑 ] |