首页    >    新闻资讯    >   手动优化你的wordpress博客SQL数据库

手动优化你的wordpress博客SQL数据库

使用wordpress博客的时候,网址打不开?图片不显示?垃圾数据太多?怎么破?

快用SQL语句,轻轻松松出困境~

这里以phpMyAdmin为例,使用时切记先备份数据库,数据有风险,操作需谨慎。

注意:下面代码中使用到的数据库前缀是wp_,请根据网址实际情况进行变更。

下面代码中的DELETE为全角状态下的大写,请自行修改为半角大写。

变更Siteurl & Homeurl

UPDATE wp_options SET option_value =

REPLACE(option_value, 'http://www.oldurl.com', 'http://www.newurl.com')

WHERE option_name = 'home' OR option_name = 'siteurl';

更改内容中的URL

UPDATE wp_posts SET post_content =

REPLACE(post_content, 'http://www.yuxiaoxi.com/blog', 'http://blog.yuxiaoxi.com')

更新文章Meta标签

UPDATE wp_postmeta SET meta_value =

REPLACE (meta_value, 'http://www.oldurl.com', 'http://www.newurl.com');

更改默认的“admin”用户名

UPDATE wp_users SET user_login = 'new-username' WHERE user_login = 'admin';

将所有的B作者的文章归入A作者

UPDATE wp_posts SET post_author = 'new-author-id' WHERE post_author = 'old-author-id';

删除草稿

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'

删除文章Meta标签

DELETE FROM wp_postmeta WHERE meta_key = 'your-metakey';

删除所有的Pingback

DELETE FROM wp_comments WHERE comment_type = 'pingback';

删除所有的垃圾评论

DELETE FROM wp_comments WHERE comment_approved = 'spam';

0 = Comment Awaiting Moderation

1 = Approved Comment

spam = Comment marked AS Spam

导出所有的评论邮件地址

SELECT DISTINCT comment_author_email FROM wp_comments;

确定未使用的标签

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;

重设密码

UPDATE wp_users SET user_pass = MD5( 'new-password' ) WHERE user_login = 'your-username';

分类:新闻资讯

标签:,

* 版权声明:作者WordPress啦! 转载请注明出处。