WordPress SQL查询命令

1. 更改WordPress地址和首页地址

UPDATE wp_options SET 
option_value = replace(option_value,
'http://www.旧网址.com', 'http://www.新网址.com') 
WHERE option_name = 'home' OR option_name = 'siteurl';

2. 更改正文中的内容

UPDATE wp_posts SET 
post_content = REPLACE (post_content,'旧内容', '新内容');

3. 重设Admin密码

UPDATE wp_users SET user_pass = MD5( 'new_password' ) 
WHERE user_login = 'admin';

4. 重设admin的用户名

UPDATE wp_users SET user_login = 'newname' 
WHERE user_login = 'admin';

5. 删除所有的垃圾评论

DELETE FROM wp_comments 
WHERE comment_approved = 'spam';

6. 禁用所有激活的插件

UPDATE wp_options SET option_value =''
WHERE option_name ='active_plugins';

7. 关闭旧文章的留言

UPDATE wp_posts SET comment_status ='closed'
WHERE post_date <'2009-01-01'AND post_status ='publish';

8. 将作者a的文章全部转移到作者b

UPDATE wp_posts SET post_author ='b'
WHERE post_author ='a';

9. 导出所有评论中的邮件地址

SELECT DISTINCT comment_author_email 
FROM wp_comments;

Leave a Reply

Your email address will not be published.