phpMyAdmin:MySQL 错误 1062 - 重复条目

发布于 2024-10-06 08:53:31 字数 734 浏览 13 评论 0原文

我将用户“root”连接到我在本地托管的数据库“test”以进行开发。其中我有“评级评论”表。由于某种原因,当我单击表“评级评论”时,phpMyAdmin 显示以下错误:

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'

我使用谷歌查找以下内容

"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."

但我仍然不太明白该错误!我使用主键,它会自动递增我的所有表,所以实际上表不应该有问题。我有另一个名为“评级”的表,其中有一列“评论”。难道这会引起问题吗?

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'

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."

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

凡尘雨 2024-10-13 08:53:31

快速修复:

REPAIR TABLE `phpmyadmin`.`pma_history`

如果失败,我只需截断/清空表。

TRUNCATE TABLE `phpmyadmin`.`pma_history`

虽然 phpmyadmin 在我的工具箱中有它的位置,但我个人不使用它的内部数据库。

ADDENDUM

MyISAM 表很容易被损坏。有几个原因经常让我困扰:如果 MySQL 没有正确关闭,或者表有 FULLTEXT 索引并且磁盘上的停用词文件已更改。

简而言之,REPAIR 只是检查数据文件是否有错误(并根据您的选择,使其再次可用)并重写索引文件。公平警告:使用 MyISAM,修复表通常可以修复该表中的所有数据,使其可用。有关更多详细信息,请参阅doc

与此 pma 表损坏有关的谷歌搜索引导我到这个< /a>.

Quick fix:

REPAIR TABLE `phpmyadmin`.`pma_history`

If that fails, I'd just truncate/empty the table.

TRUNCATE TABLE `phpmyadmin`.`pma_history`

Although phpmyadmin has it's place in my toolbox, I personally don't use it's internal db.

ADDENDUM

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.

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.

A google search pertaining to this pma table being corrupted lead me to this.

我也只是我 2024-10-13 08:53:31

这似乎是一个内部错误。您已发出此查询:

SELECT * FROM `ratingcomment`

phpMyAdmin 尝试在其内部事件日志中写入此类操作,但失败。如果您在 Google 上搜索 pma_history,您会发现对该表的多个引用已损坏。

我的建议是您找到另一个 SQL 客户端(例如 HeidiSQL)并尝试修复 phpMyAdmin 数据库。

This appears to be an internal error. You've issued this query:

SELECT * FROM `ratingcomment`

phpMyAdmin tries to write such action in its internal event log and it fails. If you Google for pma_history you'll find several references to such table being corrupted.

My advice is that you find another SQL client (such as HeidiSQL) and try to repair the phpMyAdmin database.

巷雨优美回忆 2024-10-13 08:53:31

我知道这有点晚了,但我也遇到了同样的问题,想分享我所做的事情。

在 PhpMyAdmin 中,我转到表的“操作”选项卡,仅增加“表选项”下的 AUTO_INCRMENT 值并插入一条虚拟记录。

I know this is kinda late but I had the same problem and wanted to share what I did.

In PhpMyAdmin, I went to the table's Operation tab, and just incremented the AUTO_INCREMENT value under Table options and inserted a dummy record.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文