Search and Replace WordPress using SQL Command

The format is easy to understand and can of course be used with any MySQL table, not just WordPress:

UPDATE [your_table_name] SET [your_table_field] = REPLACE([your_table_field], '[string_to_find]' , '[string_to_be_replaced]');


UPDATE wp_posts SET post_content = REPLACE(post_content, 'string_yg_diganti', 'string_pengganti');

Replace searches for certain characters in a string and replaces them with other characters. So this statement:

SELECT Replace('blablabla Rocks!', 'Rocks', 'Rolls');

will return

blablabla Rolls!

SQL Command for Clean up your WordPress Database

Delete all post revisions and their metadata

DELETE a,b,c FROM wp_posts a WHERE a.post_type = 'revision' LEFT JOIN wp_term_relationships b ON (a.ID = b.object_id) LEFT JOIN wp_postmeta c ON (a.ID = c.post_id);

Delete all unused post tags

DELETE FROM wp_terms WHERE term_id IN (SELECT term_id FROM wp_term_taxonomy WHERE count = 0 );
DELETE FROM wp_term_taxonomy WHERE term_id not IN (SELECT term_id FROM wp_terms);
DELETE FROM wp_term_relationships WHERE term_taxonomy_id not IN (SELECT term_taxonomy_id FROM wp_term_taxonomy);

Delete specific post meta

DELETE FROM wp_postmeta WHERE meta_key = 'YourMetaKey';

Clean up wp_commentmeta entries which have no relation to wp_comments

SELECT * FROM wp_commentmeta WHERE comment_id
SELECT comment_id
FROM wp_comments
DELETE FROM wp_commentmeta WHERE comment_id
SELECT comment_id
FROM wp_comments

Delete Post without article

DELETE FROM wp_posts
WHERE post_type = 'post'
AND post_content= ''

Post Tags : delete all post revisions and their metadata wordpress database, delete all post revisions and their metadata in wordpress database.

Cara Pindah File antar Server menggunakan putty (SSH)

Download putty disini:

– Buka Putty.exe, masukkan Host Name or IP Address Port diisi 22
– Tekan Open, kemudian masukkan user login, Enter
– Masukkan Password, tekan enter
– Muncul [~]#
– Ketik “dir” (tanpa tanda petik), untuk melihat directori apa aja yg ada dalam server
– ketik cd public_html [artinya change directory to public_html]
– ketik wget , klik enter, untuk medonlot file tersebut ke server kita
– Beresss…

Remove Duplicate From WordPress Quickly

Remove Duplicate From WordPress Quickly,
This is simple, Login to cpanel, and the go to phpmyadmin
Select your Blog’s mySQL database Account, (You will see a list of tables within that database). Click on SQL
Copy-past below given SQL command and click on Go:

DELETE bad_rows.*
from wp_posts as bad_rows
inner join (
select post_title, MIN(id) as min_id
from wp_posts
group by post_title
having count(*) > 1
) as good_rows on good_rows.post_title = bad_rows.post_title
and good_rows.min_id <>

Now Just wait for about a few minutes and All your Duplicate Posts will be removed magically.