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


  • | 2531 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.


  • | 262 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.

    https://wordpress.org/plugins/better-search-replace/



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