清除WordPress数据库表wp_commentmeta冗余内容

*重要*:任何数据库操作前,务必备份!

前言:WordPress从 v2.9起 从原有的10张表变成了11张表结构,新增的wp_commentmeta表很多人都不是很熟悉,如果查看一下可能会发现,该表在数据库中占用了很大的存储空间。而且所存多为冗余数据,诸如:akismet_result,akismet_history,akismet_as_submitted等。如下图:

首先,常规清理数据库:

  1. 清除已经存在的重复版本文章存档,参看我以前的文章here
  2. 可以在WP后台安装使用插件:WP-Cleanup Clean Options plugin
  3. 手动清理 wp_commentmeta ,方法:进入phpmyadmin 管理数据库,在SQL处执行下面两条语句(via 官方论坛);
Select * FROM wp_commentmeta WHERE comment_id NOT IN (SELECT comment_id FROM wp_comments);
DELETE FROM wp_commentmeta WHERE comment_id NOT IN (SELECT comment_id FROM wp_comments);

至此,wp_commentmeta 表中的冗余项(除去了有用的记录)就被清除掉了,那到底这里面存的信息有什么用呢?能不能完全清空?且往下看!

—————–HzlzH分割线—————-

事实上,wp_commentmeta 表中数据是由 Akismet 插件生成的,这里也有调用 [WP Dashboard]->[Comments],见下图:


:被博主从垃圾评论里面拉出来的评论会有这个红色区域的标记。点击之后,见下图:

———-以下操作不在本文建议范围内———–

现在清楚了,这里存着的信息是干什么事情用的,嘿嘿,是不是有想全部删除的冲动?
HzlzH执行了下面的SQL命令,整个世界清净了。

TRUNCATE TABLE `wp_commentmeta`

附 zlz.im 数据库清理后截图:(5.4MB to 4.2MB)

Done, Enjoy it!

*Important*:Backup before any step!

版权所有© HzlzH | 本文采用 BY-NC-SA 进行授权
转载需注明 转自: 《清除WordPress数据库表wp_commentmeta冗余内容

相关文章

{ Leave a Reply ? }

  1. zwwooooo China Mozilla Windows

    沙发!

    • wmtimes China Mozilla Firefox Windows

      @zwwooooo: 我是沙发中的沙发。呵呵。 我评论出不来。zww你告诉hz一下。

        • wmtimes China Mozilla Firefox Windows

          @HzlzH: 我终于付出水面了。应该是被akismit给block了。

  2. zwwooooo China Mozilla Windows

    囧,我的沙发呢?不会进spam了吧,哈哈。
    我只整理过wp_options

      • zwwooooo China Mozilla Windows

        @HzlzH: 貌似我的wp_commentmeta很小,1.2K,索引键7K,我的最大的是评论,13M……

  3. Ethan China Google Chrome Windows

    :lol: 沙发没抢到,杯具。

  4. winy United States Google Chrome Windows

    有着用途啊,试试看去

  5. Veezy China Google Chrome Windows

    瘦身成功 :D

  6. 我不在乎 China Mozilla Firefox Windows

    wp_postmeta里的东西好像也没什么用吧?

  7. 万戈 China Mozilla Firefox Windows

    恩,我很有清空它的冲动 8)

  8. WordPress啦 China Mozilla Firefox Windows

    能清理的话,还是最好清理一下,免得影响数据库。。

  9. Firm China Google Chrome Windows

    哎,数据库的东西我一直不敢动,怕删错。

    • 一灰 China Mozilla Firefox Windows

      @Firm: 备份好先就行啦。

  10. 罗伊 China Maxthon Windows

    学习一下,表示受用了。

  11. Maplews China Google Chrome Windows

    支持下~感觉挺不错的..
    还没有研究过wp的SQL

  12. 飞晏 China Google Chrome Windows

    2MB了,先存着吧~

  13. 全来主机_韩枫 China Internet Explorer Windows

    数据库不敢动啊,那玩意搞错了,容易出事。

  14. 空空裤兜 China Google Chrome Windows

    哇~wp_commentmeta不知道怎么办时放狗搜到这里了,谢谢指教啊

  15. zrqx008 China Internet Explorer Windows

    比较小,就暂时不清理了

  16. littlebearz Canada Mozilla Firefox Windows

    清理一下:)

  17. Dianso China Google Chrome Windows

    我清理了下,少了1M

  18. 拍拍网女装 China Internet Explorer Windows

    我清理了下,少了1M

  19. 东城购物 China Internet Explorer Windows

    比较小,就暂时不清理了

  20. Simon Cuba Mozilla Firefox Windows

    清理掉了320K,不错

  21. 加气混凝土设备 China Internet Explorer Windows

    啊呀呀……试试&

  22. Tiger China Opera Windows

    我用的插件

  23. wmtimes China Mozilla Firefox Windows

    对啊,这个很凡人,而且内容也多

  24. wmtimes China Mozilla Firefox Windows

    我的评论也没有了?我的更大了。14M了现在都。

      • wmtimes China Mozilla Firefox Windows

        @HzlzH: 不错。我还中了个头名。 :lol: 把那里面的数据全部删除了嘛?

  25. 小羿 China Google Chrome Windows

    被WP折腾死的路过

  26. insect China Google Chrome Windows

    过段时间就清理下数据库

  27. 精华岁月 China Internet Explorer Windows

    我也用是的插件清理的!

  28. 先看看 China SouGou Browser Windows

    这个占不了很大空间吧

  29. 奚少 China Internet Explorer Windows

    我一般只插件,对于第二个还真没注意,看看去~

  30. 沪美途网 China Mozilla Firefox Windows

    直接清空没问题吧。

  31. A.shun China Opera Windows

    wp_commentmeta 只有 10KB 左右的路过 :idea:

  32. 林木木 China Google Chrome Windows

    wp_commentmeta达到13.2 MB,一句搞定~

  33. 浩子 China Internet Explorer Windows

    最简洁的方法,本地新建一个wordpress,然后导出wp_commentmeta表,再倒入到博客数据库中,OK
    :mrgreen:
    我就这样,数据库现在才500多Kb

  34. IM路人 China Maxthon Windows

    还在用2.92的撸过~~~

  35. zbxy110 China Internet Explorer Windows

    凑个热闹,最近正在学习wp

  36. tiger China Internet Explorer Windows

    见鬼,这个表我竟然有127MB,怪不得备份出来的数据库这么大。全部清空没事吗?

    还有请问下博主,对图片装了什么插件,一点击就放大,不错。

  37. QQ名字大全 China Internet Explorer Windows

    2MB了,先存着吧~

  38. zoomao China Google Chrome Windows

    wp_commentmeta这个表达到了700多K,果断删除。

  39. Dick_Wu China Google Chrome Windows

    发现好多的博主都说这张表有问题~我也清除了!

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">

:wink: :twisted: :roll: :oops: :mrgreen: :lol: :idea: :evil: :cry: :arrow: :?: :-| :-x :-o :-P :-D :-? :) :( :!: 8-O 8)

Pingback & Trackback

  1. Zwee's blog » Blog Archive » WordPress搬家的数据库操作 United States WordPress Unknow Os - Pingback on 2011/05/21/ 12:11
  2. 清除wp_commentmeta冗余内容 - 晓潘博客 United States WordPress Unknow Os - Pingback on 2011/10/13/ 15:18