Mass Replace String in MySQL Database

When I develop websites, I do this on a staging server.

When the job is done and the customer is happy, it’s time to move it to the production server.For reasons unknown, WordPress puts the entire site path for a post in the database. This can be a bit annyoing when moving the site. Alle posts, links and other stuff points to the staging server, not the new site.

So we need to mass replace the URL And here is ther trick :)
SQL syntax
UPDATE table_name SET column_name = REPLACE(‘column_name’,'original_string’,'replace_string’)

SQL example
UPDATE `wp_posts` SET `guid` = REPLACE(`guid`,’dev1.mysite.com’,'www.newcustomer.com’)

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.