Skip to content

Instantly share code, notes, and snippets.

@IlanVivanco
Last active March 16, 2021 13:28
Show Gist options
  • Save IlanVivanco/08a272f139efa6d1b11c7ca9997e0aed to your computer and use it in GitHub Desktop.
Save IlanVivanco/08a272f139efa6d1b11c7ca9997e0aed to your computer and use it in GitHub Desktop.
Replace serialized data
SET
@search := 'https://website.com/wp-content/uploads/2019/10/the_original_image.jpg';
--COLLATE utf8mb4_unicode_520_ci;
SET
@replace := 'https://website.com/wp-content/uploads/2019/10/the_new_image.jpg';
--COLLATE utf8mb4_unicode_520_ci;
UPDATE
wp_postmeta
SET
meta_value = REPLACE(
meta_value,
CONCAT('s:', LENGTH(@search), ':"', @search, '"'),
CONCAT('s:', LENGTH(@replace), ':"', @replace, '"')
)
WHERE
meta_key = '_the_meta';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment