需要一个 MySQL 查询来删除重复的评论

发布于 2025-01-05 12:33:30 字数 214 浏览 0 评论 0原文

我的 WordPress 网站最近被黑客攻击,所以我不得不重新安装所有内容。重新安装了 WordPress,导入了数据库备份,一切都很好。然后我安装了 Disqus 插件并同步(Disqus 之前在网站被黑客攻击之前使用过)。显然是大禁忌。现在我网站上的每条评论都有副本!更糟糕的是,重复的评论已同步回 Disqus!

所以,我知道这是 PHPMyAdmin 中的一个简单查询,但我不知道!请帮忙!

My wordpress site was recently hacked so I had to reinstall everything. Wordpress resinstalled, database backups imported, everything fine and dandy. Then I installed the Disqus plugin and synced (Disqus was previously used before the site was hacked). Big no-no apparantly. Now I have a duplicate of every single comment on my site! Even worse, the duplicate comments have been synced BACK to Disqus!

So, I know this is a simple query in PHPMyAdmin but I don't know it! Please help!

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

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

发布评论

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

评论(1

南七夏 2025-01-12 12:33:30

天哪,我刚刚发布了这个,因为有人将其迁移到了 SO...!幸运的是,我在这里也有一个帐户:)

为了上帝的爱,首先备份你的数据库

我还没有尝试过这个查询,因为我没有备用数据库可以使用。

不过,这应该对您有帮助:

table1 = your table name
field_name = a field in your database.

DELETE FROM table1
USING table1, table1 as vtable
WHERE (NOT table1.ID=vtable.ID)
AND (table1.field_name=vtable.field_name)

由于它是 WordPress 评论,假设前缀为 wp,我可能会推荐......

DELETE FROM wp_comments
USING wp_comments, wp_comments as vtable
WHERE (NOT wp_comments.ID=vtable.ID)
AND (wp_comments.comment_content=vtable.comment_content)

希望有所帮助。在考虑运行此查询之前,请先阅读粗体注释。

D'oh, I just posted this as someone migrated it to SO...! Fortunately I have an account here too :)

FOR THE LOVE OF GOD BACK YOUR DATABASE UP FIRST

I haven't tried this query as I don't have a spare database to play around with.

This should help you though:

table1 = your table name
field_name = a field in your database.

DELETE FROM table1
USING table1, table1 as vtable
WHERE (NOT table1.ID=vtable.ID)
AND (table1.field_name=vtable.field_name)

As it's WordPress comments, presuming a prefix of wp, I'd probably recommend....

DELETE FROM wp_comments
USING wp_comments, wp_comments as vtable
WHERE (NOT wp_comments.ID=vtable.ID)
AND (wp_comments.comment_content=vtable.comment_content)

Hope that helps. Please read the note in bold before even contemplating running this query.

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