WordPress DB search & replace URL. How to do serialised data?

  • | 3525 points

    Hello, I am importing a live WP site so that I can make a number of changes to it locally, and then to export to live. I am easily able to do this manually by creating a quick WP app, FTPing all WP files to the new directory and then importing the DB.

    The only thing that is left outstanding are the URLs in the database which still point to the live site. As these are often serialised a simple search and replace is not sufficient enough to do this.

    On most servers (and formerly on Wampserver) I used the handy Search Replace DB from Interconnect: https://github.com/interconnectit/Search-Replace-DB
    You just place this in your WP root folder and it reads your wf-config.php file to connect to the database. Then it allows you to do all the search and replaces you need.

    This worked fine on Wampserver but it's throwing an AJAX error on Laragon. It does the initial WP DB config retrieval but when you actaully run the search and replace it stops after a minute or so with:
    "The script encountered an error while running an AJAX request.
    If you are using your hosts file to map a domain try browsing via the IP address directly."

    So my main questions are:

    1. Has anybody else used Search Replace DB from Interconnect on Laragon with success?
    2. What tools are people using to change their WP DB URL entries? I'd rather not go down the WP CLI route, or install a plugin if possible.

    Thank you.

  • | 961 points

    I manually update the siteurl and home options in the wp_options table with the Laragon URL. This will be enough to let you login to wp-admin. Then install and run Better Search Replace. It handles serialized data.


  • | 144 points

    Utilize the " wp search-replace 'oldurl.test' 'newurl.test' " command in WPCLI using the terminal in Laragon. it's also serialized and will keep you from killing any visual builders that rely on serialized data. Also for local dev or small website, the free All-In-One wp-migration plugin is amazing. I have the paid version, but the free one works well up to I think .5 gb. You can load it on your live site, export with it to maintain serialization, then just import it to a clean install with the plugin there and wang bang! but if that's not an option use the command line.

Looks like your connection to Laragon was lost, please wait while we try to reconnect.