Skip to main content
  1. All Posts/

WordPress-Database-Migration-Tool

Tools Open Source PHP WordPress
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
Copyright (C) 2011 Southwest Cyberport http://www.swcp.com/

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.


You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 

Description:

Moving a WordPress site to a new host or changing its domain can 
be a huge PITA.  This is because WP itself (as well as many plugins)
store the filesystem location and current URL of the WordPress site 
in the database.  So, simply copying your files and database may
unexpectedly break things.

Given the old and new URL's or filesystem paths, this tool updates a 
Wordpress MySQL database (it just updates wp_options and wp_posts -
seems to be the only places this is stored). 

Most importantly, it takes care to preserve serialized PHP arrays,
as many plugins now store their information in this manner.  Just doing
a SQL string REPLACE() call - as was the old way to do this - will 
"break" serialized PHP arrays in almost all cases.

Use:

Run it through Apache (recommended) by copying this folder to an Apache 
server that has access to your WordPress MySQL database.  
Running ./install.sh should fix up permissions for most folks if needed.

You may also run it from the command line:
    php move-wordpress-cli.php

which may be preferable for large databases.

You may need to increase the 'max_execution_time = x' value in your php.ini 
if this script times out.

To run in debug mode, change the return value of debug() to "true" in 
move-wordpress.inc.php.

Disclaimers:

Make sure you have a back up of your database.
This tool does not check for SQL injection. 
Restrict web access to this directory or remove it after use.

Enjoy