fbpx

This might be a simple little thing, but it’s one of those things that saves a truckload of time on a regular basis.  You set up a WordPress site on dev.joker.com so that you can build, test etc… Then you need to go live.  One of the easiest ways to do it is to download the DB, open it in BBEdit and do a search and replace for dev.joker.com/www.joker.com.  Then re-upload it and you’re ready to go.

So what happened to all of the odd characters and line breaks that someone put in without using the correct paste as text or paste from Word button?  Sometimes it works out, sometimes it doesn’t.  This all has to do with charsets and is technically just a PITA.  So what’s a way around it?

phpMyAdmin has a great search function.  Just log in, click search on the tab of the first screen like below:

then search for dev.joker.com.  The results will show you every table that you’ve got dev.joker.com in.  Next we’ll use the MySQL search and replace function:

update [table_name] set [field_name] = replace([field_name],'[string_to_find]’,'[string_to_replace]’);

It’s a pretty straight forward code that I didn’t discover for a couple of years simply because I never thought to look for it (duh…)  what it does is allows you to search and replace any string on any field.  It does NOT search the entire DB which would be great, but once you’ve gotten the list of instances from the global search you did via phpMyAdmin earlier, then you just have to go down through the tables and fields and you’ll be good to go.

One quick note.  The post_content and guid fields in the wp_posts table will both have instances.  You’d figure it out, but I’m just trying to save you a little time.