Last active
November 30, 2016 02:17
-
-
Save senooat/2581b35695c7b5d040ce83c386568580 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//サイトのURLを変更する | |
UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldsiteurl.com', 'http://www.newsiteurl.com') WHERE option_name = 'home' OR option_name = 'siteurl'; | |
//画像のパスを変更する | |
UPDATE wp_posts SET post_content = REPLACE (post_content, 'http://www.oldsiteurl.com', 'http://www.newsiteurl.com'); | |
//Metaを変更 | |
UPDATE wp_postmeta SET meta_value = REPLACE (meta_value, 'http://www.oldsiteurl.com','http://www.newsiteurl.com'); | |
//デフォルトのユーザー名である「admin」を変更する | |
UPDATE wp_users SET user_login = '新しいユーザー名' WHERE user_login = 'admin'; | |
//パスワードのリセット | |
UPDATE wp_users SET user_pass = MD5( 'new_password' ) WHERE user_login = 'your-username'; | |
//投稿者を変更する | |
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-meta-key'; | |
//コメント投稿者のメールアドレスを抽出する | |
SELECT DISTINCT comment_author_email FROM wp_comments; | |
//トラックバックを削除 | |
DELETE FROM wp_comments WHERE comment_type = 'pingback'; | |
//スパムコメントを削除する | |
DELETE FROM wp_comments WHERE comment_approved = 'spam'; | |
//未使用のタグを削除 | |
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; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment