Coolest Guides on the Planet

coolest guides on the planet

Coolest Guides On The Planet

  • Home
  • macOS
  • WebDev
  • All Posts
  • Contact

Migrate WordPress Site from Local Development to Live Server and fix serialized data issues

July 23, 2014 Leave a Comment

There are a number of ways to migrate a local development WordPress site from a test to a live server, you can to this manually or via a plugin.

Migrating WordPress Manually

The manual way to migrate a WordPress site to a live server is in a few steps:

  • Copy the all the contents of the WordPress installation in your development webroot to your webroot in your live server via FTP, cPanel or other transfer method.
  • Export/Dump your development MySQL database
  • Create a new MySQL database for your live environment
  • Import the development database into the blank live environment database
  • Change the URLs in the database from old to new
  • Update /wp-config.php file for new database, database username and password

If you have created your test site with a different URL then the finishing live site which is more than likely, (unless you are using Virtual Hosts and are swapping between local and remote IP addresses) you may run into issues with some data not being migrated to the live site.

This data may include WordPress widgets not showing, certain plugins or theme data is missing. The reason this data may not have made the migration trip is because it is lost as the data has been serialized in the database with the old URL and then can’t be unserialized as there is a new URL.

Serialized Data

So what is Serialized data?  Well it is data that has been written as an array in PHP and stored as a string in one field in a database as appose to numerous fields in a mysql database. This allows a developer an easy, quick and efficient set up but comes at the price of serializing and unserializing that data.

WordPress uses its own serialization functions, however the disadvantage of this approach is that the data is now not as easily transported to say a new URL as the URL is used as part of the serialization.

Temporarily Fixing Serialized Data Issues

To get you out of an immediate bind and show any missing data after a migration you can edit a function in a core WordPress file:

/public_html/wp-includes/functions.php

Comment out the function maybe_unserialize() on lines 230-234 and replace with:

function maybe_unserialize( $original ) {
    if ( is_serialized( $original ) ) {
        $fixed = preg_replace_callback(
            '!(?<=^|;)s:(\d+)(?=:"(.*?)";(?:}|a:|s:|b:|i:|o:|N;))!s',
            'serialize_fix_callback',
            $original );
        return @unserialize( $fixed );
    }
    return $original;
}
function serialize_fix_callback($match) { return 's:' . strlen($match[2]); }

Obviously you will lose that when WordPress is upgraded and is not considered best practice so a permanent solution is required.

Permanent Fix for Serialized Data Issues

The better way to go out this is exporting a database which already references the new URL of the live environment and this is where WP-Migrate DB sorts out the problem. Install the plugin in your development site and export the database with the new URL and file path stated.

migrate-wordpress-database

Once this is done just import the exported database into the new live server.

Also is a script from interconnectit/Search-Replace-DB which is a wizard you can use which changes the domain name whilst keeping serialized data intact.

 

 

WordPress Migration Plugins

migrate wordpress siteA couple of WordPress plugins that can deal with migrating a site from development to live server and deal with any data serialization issues are Duplicator and BackUp Buddy the former is free and the latter is a commercial plugin. One of the key benefits of BackUp Buddy is that it can migrate WordPress Multi-Site installations.

I use mostly Duplicator which I have found to be faultless in many site migrations and the plugin has been around for a while now.

You add the plugin to the the site you are migrating from and create a package from the plugin which includes all the WordPress content and the database, you upload that package to your new server and you need to have a blank MySQL database ready.

From there you need the credentials of the new database; name, username and password – after the package is uploaded go to the config file via a browser, fill in the blanks and you have a migrated site.

Here are the full Duplicator docs.

 

Cats: Database, Tech, WordPress

Tags

3gs 10.6 apache backup baseband boot clean urls cpanel css curl custom database drupal el capitan git Google image instadmg ios iphone jailbreak keys lion mac macos mojave macos sierra menu mysql OSX panda php phpmyadmin private public redirect redsn0w remote rsa SEO shell ssh terminal unstoppables upgrade urls

Donate a Beer to the Coolest Guides

Get Beaver Builder Now!

Discuss

3gs 10.6 apache backup baseband boot clean urls cpanel css curl custom database drupal el capitan git Google image instadmg ios iphone jailbreak keys lion mac macos mojave macos sierra menu mysql OSX panda php phpmyadmin private public redirect redsn0w remote rsa SEO shell ssh terminal unstoppables upgrade urls
Get DesktopServer

Lynda

Lynda.com Online Training Videos

TreeHouse

smlinks

Learn WordPress
osx-modify-shell-path

How to Add to the Shell Path in macOS Big Sur and Catalina using Terminal

October 19, 2019

virtual-hosts osx 10.10 yosemite

Set up Virtual Hosts on macOS Catalina 10.15 in Apache

October 19, 2019

Installing Homebrew on macOS Catalina 10.15, Package Manager for Linux Apps

October 18, 2019

Where is the bash shell in macos Catalina?

October 12, 2019

Refine your search

  • All
  • Modules
  • Themes
  • Documentation
  • Forums & Issues
  • Groups

RSS ars technica

  • Musi says evidence shows Apple conspired with music industry on App Store ban
  • Trump threatens Apple with 25% tariff to force iPhone manufacturing into US
  • I helped a lost dog’s AirTag ping its owner: An ode to replaceable batteries
  • Apple legend Jony Ive takes control of OpenAI’s design future
  • Epic goes to court to force Fortnite back on US iOS

RSS mac surfer

  • Tot is new text editor for Mac, iPhone, and iPad focused on constraints and ease of use
  • TiPbITS: Google Drive Sorting Can Hide New Documents
  • How to take a screenshot on a MacBook Pro
  • How To Create Simple Animation With Mac Keynote
  • Last Week on My Mac: Virus pandemics

Donate

Copyright © 2025· Neil Gee - All Rights Reserved - Hosted by Runcloud

Copyright © 2025 · gee on Genesis Framework · WordPress · Log in