[wp-hackers] change siteurl at DB level

Jerry Johnson jmiloj at gmail.com
Tue Aug 24 20:52:22 UTC 2010


Andrew,

You might have a problem with that script, if any of your wp_options have a
serialized string containing the url (like an rss feed url), since the
length of the string will no longer match the serialized string length
value. If so, you might want to only replace a few known records in the
wp_options table which have the entire unserialized string)

Also, look at the guid field in your posts table, to see if you have the old
url in there as well.

(We use wp-mu still, so my scripts are a little different, but we handle
those 2 cases I mention above in addition to yours. We also search/replace
in the wp_blogs and wp_site tables)

Just a thought,
Jerry Milo Johnson



> On Tue, Aug 24, 2010 at 3:18 PM, Andrew Gray <andrew at graymerica.com>
> wrote:
>
> > I have been trying to move a site from  development.domain.com  to
> > domain.com all day and got fed up and wrote some SQL to make the change
> on
> > the DB level.
> > I know that you can download the DB dump and fix it, but it causes some
> > problems for me with UTF characters.  Also some of my sites are pretty
> big
> > now, with all the revisions, custom post types and what not.
> >
> > If you run this command, you can pretty much change all of the stock
> > tables.
> >
> > This will not change all your plugins values, but saved me a ton of time.
> > Took about 1 sec to run
> >
> >
> > #Change Domain in in Wordpress DB
> > #before you run this command in SQL (phpmyadmin)
> > # 1. Backup DB
> > # 2. Find and replace the text below in your text editor
> > #replace $old$ with the old domain name
> > #replace  $new$ with the new domain name
> >
> > update wp_postmeta set meta_value = replace(meta_value, '$old$' ,
> '$new$')
> > ;
> > update wp_posts set post_content = replace(post_content, '$old$' ,
> '$new$')
> > ;
> > update wp_options set option_value = replace(option_value, '$old$' ,
> > '$new$') ;
> >
> > #end sql command
> >
> > I would love it if there was an easy way to force wordpress to use a
> place
> > holder for the domain and then replace in the correct one when it reads
> from
> > the DB.
> > If I could find a filter that would filter every value from read and
> write
> > to the db, I could do this very easy, but there is no filter for every
> value
> > coming from the DB.
> > I just do not know why the SITEURL should be stored in the DB.  Is there
> a
> > pair of filters that I can use to replace a value in every read and write
>


More information about the wp-hackers mailing list