wordpress 本身是动态程序,像电脑系统一样也会生成很多的垃圾,日后可能会很吃服务器资源,下面教大家怎么清理。匡
清除草稿
wordpress 会自动保存草稿,每次修改都会保留之前的修订版本,执行下面SQL语句就能完全删除。
DELETE a,b,c FROM wp_posts a
LEFT JOIN wp_term_relationships b ON (a.ID = b.object_id)
LEFT JOIN wp_postmeta c ON (a.ID = c.post_id)
WHERE a.post_type = 'revision'
清除垃圾
wordpress 删除主题、插件会有残留表数据,执行下面SQL语句就能完全删除。
DELETE FROM wp_postmeta WHERE meta_key = '_edit_lock';
DELETE FROM wp_postmeta WHERE meta_key = '_edit_last';
清除标签
删除文章,添加的标签不会自动删除,依然在标签列表中,执行下面SQL语句就能删除未归档的标签。
SELECT * FROM wp_terms wt
INNER JOIN wp_term_taxonomy wtt ON wt.term_id=wtt.term_id
INNER JOIN wp_term_relationships wtr ON wtr.term_taxonomy_id=wtt.term_taxonomy_id
LEFT JOIN wp_posts wp ON wp.ID=wtr.object_id
WHERE taxonomy='post_tag'
AND ID IS null
AND NOT EXISTS(SELECT * From wp_terms wt2
INNER JOIN wp_term_taxonomy wtt2 ON wt2.term_id=wtt2.term_id WHERE wtt2.parent=wt.term_id) ORDER BY name;
优化数据库
完成上述操作后,还需要全选表文件,点击修复表、优化表。
原创文章,作者:霍欣标,如若转载,请注明出处:https://www.yijing21.cn/seo/110.html