最新消息:duha.net 大杂烩。

清除wordpress无用的数据库信息

所有文章 Huishu 4066浏览 0评论

直接上sql代码

DELETE FROM wp_posts WHERE post_type = ‘revision’;
DELETE FROM wp_posts WHERE post_status = ‘draft’;
DELETE FROM wp_posts WHERE post_status = ‘auto-draft’;
DELETE FROM wp_comments WHERE comment_approved = ‘0’;
DELETE FROM wp_comments WHERE comment_approved = ‘spam’;
DELETE FROM wp_comments WHERE comment_approved = ‘trash’;
DELETE pm FROM wp_postmeta pm LEFT JOIN wp_posts wp ON wp.ID = pm.post_id WHERE wp.ID IS NULL;
DELETE FROM wp_commentmeta WHERE comment_id NOT IN (SELECT comment_id FROM wp_comments);
DELETE FROM wp_term_relationships WHERE term_taxonomy_id=1 AND object_id NOT IN (SELECT id FROM wp_posts);
DELETE FROM wp_options WHERE option_name LIKE ‘_site_transient_browser_%’ OR option_name LIKE ‘_site_transient_timeout_browser_%’ OR option_name LIKE ‘_transient_feed_%’ OR option_name LIKE ‘_transient_timeout_feed_%’;

优化数据表,可以用以下的语句:

OPTIMIZE TABLE wp_commentmeta;
OPTIMIZE TABLE wp_comments;
OPTIMIZE TABLE wp_links;
OPTIMIZE TABLE wp_options;
OPTIMIZE TABLE wp_postmeta;
OPTIMIZE TABLE wp_posts;
OPTIMIZE TABLE wp_terms;
OPTIMIZE TABLE wp_term_relationships;
OPTIMIZE TABLE wp_term_taxonomy;
OPTIMIZE TABLE wp_usermeta;
OPTIMIZE TABLE wp_users;

以下强迫症收集
insert into `wp_options` (option_name,option_value,autoload) select option_name,option_value,autoload from `wp_options1` order by option_id
insert into `wp_postmeta` (post_id,meta_key,meta_value) select post_id,meta_key,meta_value from `wp_postmeta1` order by post_id,meta_key
SELECT * FROM `wp_postmeta` where meta_value like “%unknown%”
update `wp_postmeta` as a,wp_posts as b set a.meta_value=UNIX_TIMESTAMP(b.post_date) where a.post_id=b.ID and a.meta_key=”_edit_lock”
update `wp_postmeta` set meta_value=CONCAT(meta_value,’:1′) where meta_key=’_edit_lock’
update `wp_postmeta` set meta_value=FLOOR(RAND()*10) + 1200 where meta_key=’views’

转载请注明:duha.net » 清除wordpress无用的数据库信息

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址