Last Updated: September 06, 2020
·
298
· andreekeberg

Replace domains in WordPress databases without corrupting serialized data

The easiest way to move a WordPress website from one domain to another is to create a MySQL database dump and import this data into the new website. However, if the domain or URL of the new website is different from the old one, then this process is no longer enough.

For example, when a WordPress website is created for a client in a development environment and then later moved to the client's domain, all of the occurrences of the old domain or URL within the database need to be replaced with the new one otherwise links and images will still point to the development environment.

One solution is to perform a text based "search and replace" on the database dump, but this is likely to result in lost data, because a WordPress database likely includes serialized PHP objects, which are strings PHP uses to store complex objects as text data. A serialized string not only stores the value of a object but also its size (number of characters), therefore if the old and the new domains or URLs have different character counts, PHP will not be able to recreate the original object anymore.

This online tool solves this problem by letting you replace an old domain or URL with a new one while fixing the serialized data at the same time.