Skip to content

Instantly share code, notes, and snippets.

@peacefulseeker
Last active November 27, 2017 16:24
Show Gist options
  • Save peacefulseeker/965e3c903b3a44e641fa182b0386e872 to your computer and use it in GitHub Desktop.
Save peacefulseeker/965e3c903b3a44e641fa182b0386e872 to your computer and use it in GitHub Desktop.
WordPress - Replace data within WordPress Database
-- Define the repeating string to replace in database table, as well as the string that should be replaced by.
-- SET @what_to_be_replaced = "http://dev.sehner.international", @to_be_replaced_by = "https://sehner.international";
SET @what_to_be_replaced = "https://www.pflegemarkt.com", @to_be_replaced_by = "http://dev.pflegemarkt.com";
-- Update every table columns that usually contains wrong domain(local development or dev version of website)
-- You should provide collation of table as well for the following tables, otherwiser it will throw the error, usually it is COLLATE utf8mb4_general_ci.
-- THESE ARE DEFAULT TABLES OF WORDPRESS
UPDATE pm_commentmeta SET meta_value = REPLACE(meta_value, @what_to_be_replaced, @to_be_replaced_by );
UPDATE pm_comments SET comment_content = REPLACE(comment_content, @what_to_be_replaced ,@to_be_replaced_by);
UPDATE pm_links SET link_description = REPLACE(link_description, @what_to_be_replaced, @to_be_replaced_by);
UPDATE pm_options SET option_value = REPLACE(option_value, @what_to_be_replaced, @to_be_replaced_by);
UPDATE pm_postmeta SET meta_value = REPLACE(meta_value, @what_to_be_replaced, @to_be_replaced_by);
UPDATE pm_posts SET post_content = REPLACE(post_content, @what_to_be_replaced, @to_be_replaced_by);
UPDATE pm_posts SET guid = REPLACE(guid, @what_to_be_replaced, @to_be_replaced_by);
UPDATE pm_posts SET post_title = REPLACE(post_title, @what_to_be_replaced, @to_be_replaced_by);
UPDATE pm_posts SET post_excerpt = REPLACE(post_excerpt, @what_to_be_replaced, @to_be_replaced_by);
UPDATE pm_term_taxonomy SET description = REPLACE(description, @what_to_be_replaced, @to_be_replaced_by);
UPDATE pm_usermeta SET meta_value = REPLACE(meta_value, @what_to_be_replaced, @to_be_replaced_by);
-- Optional query for plugin specific table that contains wrong domain of website.
-- REVOLUTION SLIDER TABLES
-- UPDATE si_revslider_slides SET layers = REPLACE( layers, @what_to_be_replaced , @to_be_replaced_by );
-- UPDATE si_revslider_slides SET params = REPLACE( params, @what_to_be_replaced , @to_be_replaced_by );
-- UPDATE si_revslider_sliders SET params = REPLACE( params, @what_to_be_replaced , @to_be_replaced_by );
-- -- WPML PLUGIN TABLES
-- UPDATE si_icl_string_positions SET position_in_page = REPLACE( position_in_page, @what_to_be_replaced , @to_be_replaced_by );
-- UPDATE si_icl_strings SET value = REPLACE( value, @what_to_be_replaced , @to_be_replaced_by );
-- UPDATE si_icl_translation_status SET translation_package = REPLACE( translation_package, @what_to_be_replaced , @to_be_replaced_by );
-- -- ALL IN ONE WP SECURITY PLUGIN TABLES
-- UPDATE si_aiowps_global_meta SET meta_value4 = REPLACE( meta_value4, @what_to_be_replaced , @to_be_replaced_by );
-- UPDATE si_aiowps_global_meta SET meta_value5 = REPLACE( meta_value5, @what_to_be_replaced , @to_be_replaced_by );
-- -- Main WP Worpdress management tool Tables
-- UPDATE si_gpi_page_reports SET rule_blocks = REPLACE( rule_blocks, @what_to_be_replaced , @to_be_replaced_by );
-- UPDATE si_gpi_page_stats SET URL = REPLACE( URL, @what_to_be_replaced , @to_be_replaced_by );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment