But suppose your WordPress website on hundreds of articles, but you need to be changes in the scope of total station, then detailed editing from the background is a bit time consuming, and the rate of mistakes will improve. Is the best way to enter the WordPress MySQL database to perform the necessary queries (changes). Through the MySQL can quickly finish above tasks, saving more time for you.

this is to introduce some time WordPress SQL query method.
INSERT INTO wp_postmeta (post_id, meta_key meta_value)
SELECT ID AS post_id, 'UniversalCustomField'
AS meta_key 'MyValue AS meta_value FROM wp_postsWHERE ID NOT IN (SELECT post_id FROM wp_postmeta WHERE meta_key=' UniversalCustomField ');

if you only need to add custom fields to the article, can use the code below:

INSERT INTO wp_postmeta (post_id, meta_key meta_value)
SELECT ID AS post_id, 'UniversalCustomField'
AS meta_key 'MyValue AS meta_value
the FROM wp_posts WHERE ID NOT IN
(SELECT post_id FROM wp_postmeta WHERE meta_key=' UniversalCustomField ') ` ` AND post_type='post';

if only needed for the page to add custom fields, can use the code below:

INSERT INTO wp_postmeta (post_id, meta_key meta_value)
SELECT ID AS post_id, 'UniversalCustomField'
AS meta_key 'MyValue AS meta_value
the FROM wp_posts WHERE ID NOT IN
(SELECT post_id FROM wp_postmeta WHERE meta_key=' UniversalCustomField ') AND ` post_type `='page';


delete articles meta data when you install or remove the plugin system through post meta tags to store data. Plug-in is deleted after, the data will still remain in the post_meta table, of course when you no longer need these data, can be deleted completely. Remember that in the code before running the query 'YourMetaKey' replaced with the corresponding value you need.

DELETE FROM wp_postmeta WHERE meta_key='YourMetaKey';

find useless tag
if you are in the WordPress database query is executed to delete the old post, and delete a plugin before, the article belongs to label will remain in the database, and also list appears in the label/tag clouds. The following query can help you to find out useless labels.

SELECT * From wp_terms wtINNER JOIN wp_term_taxonomy WTT>
DELETE From wp_comments WHERE wp_comments.com ment_approved='spam';

batch delete all had approved comments
the SQL query will erase everything on your website did not review comments, shall not affect the approved comments.

DELETE FROM wp_comments WHERE comment_approved=0

prohibit comments earlier article
the value at the specified comment_status open, closed or registered_only.
in addition also need to SET the date (2010-01-01) in modifying code:

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

deactivate/activate the trackback with pingback
the value at the specified comment_status open, closed or registered_only. To all pingbacks/user activation with trackbacks
:

UPDATE wp_posts SET ping_status='open';

to all users: disable pingbacks/with trackbacks

UPDATE wp_posts SET ping_status='closed';

activate/deactivate the Pingbacks before a certain date &with Trackbacks
the value at the specified ping_status open, closed or registered_only.
in addition also need to SET the date (2010-01-01) in modifying code:

UPDATE wp_posts SET ping_status='closed' WHERE post_date <'2010-01-01' AND post_status='publish';

delete comments specific URL
when you find a lot of spam comments with the same URL links, you can use the following query one-time delete these comments. According with "% %" symbols in all of the URL string will be removed.

DELETE from wp_comments WHERE comment_author_url LIKE nastyspamurl "% %";

to identify AND remove the "X" days ago article
looking for "X" days ago all the posts (note that the X replaced with the corresponding number) :

SELECT * FROM ` wp_posts ` WHERE ` post_type `='post' AND DATEDIFF (NOW (), ` post_date `) >X

remove "X" days ago all articles:

DELETE FROM ` wp_posts ` WHERE ` post_type `='post' AND DATEDIFF (NOW (), ` post_date `) >X


delete unwanted short code when you decided not to use a short code, they won't disappear automatically. You can use a simple SQL query command removes all don't need to short code. "Tweet" replace corresponding short code name:

UPDATE wp_post SET post_content=replace (post_content, '[tweet]', ');


the articles into page still just by running an SQL query can get PHPMyAdmin:

UPDATE wp_posts SET post_type='page' WHERE post_type='post'

the page into articles:

UPDATE wp_posts SET post_type='post' WHERE post_type='page'

to change all the article the author attribute
first by using the following SQL command to retrieve the ID:

SELECT ID, display_name FROM wp_users;

successfully get the author's ID, old and new, insert the following command, remember to replace with new author ID NEW_AUTHOR_ID, replace OLD_AUTHOR_ID old author ID.

UPDATE wp_posts SET post_author=NEW_AUTHOR_ID WHERE post_author=OLD_AUTHOR_ID;

batch delete article revision history
the article revision history preservation can be very practical, can be very annoying. You can manually delete the revision history, also can use the SQL queries to save time for yourself.

DELETE FROM wp_posts WHERE post_type="revision";

deactivate/activate all WordPress plugin
after activating a plugin can not log in your WordPress admin panel, try the following query command, it will immediately disable all plug-in, allows you to log back in.

UPDATE wp_options SET option_value='http://www.script-home.com//article/a:0: {} WHERE option_name=' active_plugins';

the changes to the WordPress site target URL
the WordPress blog (template file, upload content &database from one server to another server, then you need to tell your new WordPress blog address.
using the following command, pay attention to replace http://www.old-site.com with your original URL, http://blog.doucube.com to the new URL.
first:

UPDATE wp_options
SET option_value=http://www.script-home.com//article/replace (option_value, 'http://www.old-site.com', 'http://blog.doucube.com')
WHERE option_name='home' OR option_name='siteurl';

and then use the following command to change wp_posts in URL:

UPDATE wp_posts SET guid=replace (guid, 'http://www.old-site.com', 'http://blog.doucube.com);

in the end, search the article content to ensure that the new URL link with the original no confused:

UPDATE wp_posts SET post_content=replace (post_content, 'http://www.ancien-site.com', 'http://blog.doucube.com');

to change the default user name Admin
among them YourNewUsername replaced with a new username.

UPDATE wp_users SET value for user_login='YourNewUsername' WHERE value for user_login='Admin'; Manual reset WordPress PASSWORD


if you are the only author on your WordPress site, and you did not change the default user name, then you can use the following SQL queries to reset PASSWORD (change the PASSWORD to a new PASSWORD) :

UPDATE ` WordPress `. ` wp_users ` SET ` user_pass `=MD5 (" PASSWORD ")
WHERE ` wp_users `. ` value for user_login `=` admin ` LIMIT 1;


search and REPLACE text is replaced OriginalText into content, ReplacedText to target content:

UPDATE wp_posts SET ` post_content `=REPLACE (` post_content `, 'OriginalText', 'ReplacedText');

to change the image URL
the following SQL command can help you to modify the image path:

UPDATE wp_postsSET post_content=REPLACE (post_content, 'SRC=' http://www.myoldurl.com ', 'SRC="http://blog.doucube.com");


This concludes the body part