Here’s a couple things I always forget. I’m adding them here so I’ll have them for future reference.
How to “Scan and Replace” a String in MYSQL
(Note the AS400-ish wording of that title).
Big Note: Be very careful of serialized data!!!!
Thanks to http://www.mydigitallife.info/how-to-find-and-replace-text-in-mysql-database-using-sql/ for these little pieces of code.
The syntax of REPLACE is REPLACE(text_string, from_string, to_string)
update TABLE_NAME set FIELD_NAME = replace(FIELD_NAME, 'find this string', 'replace found string with this string');
update wp_posts set post_content = replace(post_content, 'http://domain.com/blog/', 'http://domain.com/')
The above statement will replace all instances of 'http://domain.com/blog' to 'http://domain.com/' in the field of post_content of wp_posts table.
(I actually used the code above to “transfer” a bunch of image referencess from a WordPress install in a folder up to the root domain).
How to Search for a String in an Entire MYSQL Database
After doing “scans and replaces” it may be necessary to check your work. Here’s the trick.
Log into PHPMYADMIN and highlight (select) the entire database. Click search. You will see a screen something like this:
You must put in your SQL-syntax wildcard and select the tables to search. Click Go, and you’ll see: