phpMyAdmin:MySQL错误1062-重复输入 [英] phpMyAdmin: MySQL Error 1062 - Duplicate entry
问题描述
我用用户"root"连接到我的数据库"test"上,该数据库在本地托管以进行开发.除其他外,我还有表格"ratingcomment".由于某些原因,当我单击表"ratingcomment"时,phpMyAdmin向我显示以下错误:
I connect with user "root" onto my database "test" which I host locally for development. Among others I have the table "ratingcomment". For some reason when I click on the table "ratingcomment" phpMyAdmin shows me the following error:
Fehler
SQL-Befehl:
INSERT INTO `phpmyadmin`.`pma_history` (
`username` ,
`db` ,
`table` ,
`timevalue` ,
`sqlquery`
)
VALUES (
'root', 'test', 'ratingcomment', NOW( ) , 'SELECT * FROM `ratingcomment`'
)
MySQL meldet:
#1062 - Duplicate entry '838' for key 'PRIMARY'
我用Google查找以下内容
I used google to finde out the following
"This indicates that you have a UNIQUE or PRIMARY index on a table, and there is a duplicate value someone on one of the values in one of these indexes."
但是我还是不太明白这个错误!我使用一个主键,该键会为我的所有表自动递增,因此该表实际上不应该出现问题.我还有一个名为"rating"的表,其中有一个"comment"列.可能会引起问题吗?
But I still dont quite understand the error! I use a primary Key, which auto-increments for all of my tables, so there actually shouldnt be a problem with the table. I had another table named "rating" which had a column "comment". Can it be, that this causes problems?
推荐答案
快速修复:
REPAIR TABLE `phpmyadmin`.`pma_history`
如果失败,我将截断/清空表.
If that fails, I'd just truncate/empty the table.
TRUNCATE TABLE `phpmyadmin`.`pma_history`
尽管phpmyadmin在我的工具箱中有它的位置,但我个人不使用它的内部数据库.
Although phpmyadmin has it's place in my toolbox, I personally don't use it's internal db.
附录
MyISAM表很容易损坏.导致这种情况的常见原因有两个:如果MySQL未正确关闭,或者表具有FULLTEXT索引并且磁盘上的停用词文件已更改.
MyISAM tables can easily become corrupted. A couple causes that usually hit me: if the MySQL is not shutdown properly, or if the table has a FULLTEXT index and the stopword file on disk had changed.
简单地说,REPAIR
只是检查数据文件是否有错误(并根据您的选择使其再次可用)并重写索引文件.合理的警告:使用MyISAM,修复表通常可以烘烤该表中的所有数据以使其成为usable
.有关更多详细信息,请参见 doc .
Simply stated, the REPAIR
just checkes the data file for errors (and depending on your options, makes it usable again) and rewrites the index file. Fair warning: with MyISAM, repairing a table can often toast all your data in that table to make it usable
. See doc for more details.
与该pma表有关的Google搜索被损坏,导致我进入此.
A google search pertaining to this pma table being corrupted lead me to this.
这篇关于phpMyAdmin:MySQL错误1062-重复输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!