Sarah Moyer

WordPress Development for Web Agencies

  • Home
  • Work with Me
    • for Agencies
    • for Designers
    • for Business Owners
    • FAQs
    • Website Care
  • Portfolio
  • Blog
  • Contact

Find and Replace Domain in phpMyAdmin

Last updated on March 31, 2018 · Posted in How To · domain  · errors  · phpmyadmin  · url

Change wp_options siteurl and home, manually or with this:

UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldurl', 'http://www.newurl') WHERE option_name = 'home' OR option_name = 'siteurl';

ref: https://coolestguidesontheplanet.com/updating-wordpress-mysql-database-after-moving-to-a-new-url/

Test.

links in style.css
links in menu (esp. custom)
links in widgets
links in post content
links in white label cms
links in footer

UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldurl', 'http://www.newurl') WHERE option_name = 'home' OR option_name = 'siteurl';

UPDATE wp_posts SET guid = replace(guid, 'http://www.oldurl','http://www.newurl');

UPDATE wp_posts SET post_content = replace(post_content, 'http://www.oldurl', 'http://www.newurl');

UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.oldurl','http://www.newurl');

If your tables have abc_posts instead of wp_posts, you will have to change the actual data above.

Click Simulate Query so you can see what it will change before it actually does.

Was this post helpful?

Comments

  1. Sal Ferrarello says

    November 7, 2017 at 5:42 pm

    First, I want to say I love these posts you are creating documenting some of your practices.

    I do want to point out a problem with using this statement.

    UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.oldurl','http://www.newurl');

    While this seems perfectly reasonable that you’re updating all instances of your old URL to the new URL in wp_postmeta, a problem occurs if the URL appears in a serialized value. With a serialized value, something like an array can be stored in a single field in the database. The problem that arises is when the data is serialized, each value that is stored as a string and also has a value indicating its length. If the new URL is a different length than the old URL, this is going to cause problems. See https://stackoverflow.com/questions/15138893/fix-serialized-data-broken-due-to-editing-mysql-database-in-a-text-editor.

    Fortunately, there are some tools for doing a search and replace in serialized data and updating these length values. I’m a big fan of using WP CLI search-replace.

    Search/replace intelligently handles PHP serialized data

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Comments Protected by WP-SpamShield Anti-Spam

Recommended Resources

Copyright © 2025 by Sarah Moyer · Privacy Policy