How to Migrate and Update the WordPress URLS in Database

By | WordPress | No Comments

After migrating a WordPress site to a new URL either to a live production site or a testing development server, the new URL strings in the mysql database need to be changed and updated in the various mysql database tables.

This method just uses the whole mysql database rather than a WordPress export/import from within, and is best suited for a straight swap. So you would copy all the WordPress files/folders to the new destination, set the correct ownership to those files,  then run the database update / migration script.

WordPress Database Manual Migration

First, do a mysql database export of the old database on the old server, create a new blank database on the new server, import the old data either in phpmyadmin.

Make sure you have the new database selected, then run some sql updates and replacement commands on the tables notably, wp_options, wp_posts, wp_postmeta.

Use the code as below and swap in your old and new URLs, no trailing slashes. Also if necessary change the table prefix values where applicable (ie wp_ )

UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldurl', 'http://www.newurl') WHERE option_name = 'home' OR option_name = 'siteurl';

UPDATE wp_posts SET guid = replace(guid, 'http://www.oldurl','http://www.newurl');

UPDATE wp_posts SET post_content = replace(post_content, 'http://www.oldurl', 'http://www.newurl');

UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.oldurl','http://www.newurl');




or via command line:

[email protected][~/Desktop]: mysql -u root -p databasename
Enter password:
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 892
Server version: 5.5.13 MySQL Community Server (GPL)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

mysql> UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldurl', 'http://www.newurl') WHERE option_name = 'home' OR option_name = 'siteurl';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 2 Changed: 0 Warnings: 0

mysql> UPDATE wp_posts SET guid = replace(guid, 'http://www.oldurl','http://www.newurl');
Query OK, 0 rows affected (0.02 sec)
Rows matched: 964 Changed: 0 Warnings: 0

mysql> UPDATE wp_posts SET post_content = replace(post_content, 'http://www.oldurl', 'http://www.newurl');
Query OK, 0 rows affected (0.05 sec)
Rows matched: 964 Changed: 0 Warnings: 0

mysql> UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.oldurl','http://www.newurl');g
Query OK, 0 rows affected (0.01 sec)
Rows matched: 686 Changed: 0 Warnings: 0

Finally update your WordPress config file to reflect the new database, wp-config.php” which should be in your web document root – change, databasenameusernamepasswordand host values:

define('DB_NAME', 'databasename');

/** MySQL database username */
define('DB_USER', 'username');

/** MySQL database password */
define('DB_PASSWORD', 'password');

/** MySQL hostname */
define('DB_HOST', 'localhost');

Now everything should link up perfectly.

djave has created a nice and easy script that takes the old and new URLs and hands you the sql code for the WordPress swap, nice!

Serialized Data

Sometimes issues may arise with a problem called serialized data which is when an array of PHP data is somewhat like encyrpted with the actual URL, so if the URL is changed the data is gone.

There are 2 brilliant tools that can handle serialized data and do a search and replace on the old and new databases for the URL and leave serialized data intact.


First up is a script you run via uploading it and browsing to it after migrating and importing your old database into the new – this will then make those necessary changes. Get it from here.

WordPress 4.5.1 Released

By | WordPress | No Comments

WordPress 4.5.1 is available and addresses a dozen items reported against WordPress 4.5. According to Adam Silverstein, “a singular class issue that broke sites based on the Twenty Eleven theme, an incompatibility between certain Chrome versions and the visual editor, and an Imagick bug that could break media uploads,” are among the bugs fixed. A detailed list of changes can be viewed here.

WordPress 4.5.1 is already being pushed out to sites configured for auto updates. If you’d rather not wait or have auto updates disabled, you can browse to Dashboard – Updates and click the Update Now button. If you encounter an issue or believe you’ve discovered a bug, please post it in the troubleshooting section of the support forums.

WordPress 4.5 targeted to release in April 2016

By | WordPress | No Comments

WordPress 4.5, the next version of WordPress is already in development and is targeted to release in April 2016.

We just saw the release of WordPress 4.4, and the latest security and maintenance version WordPress 4.4.1 was released earlier this week.

The core development team has now published a project schedule targeting its release in mid-April. The current target release date is April 12, 2016.

The beta-1 version of WordPress 4.5 is planned to release by the end of upcoming February, and three more beta versions of the software will be released before the final release candidate.

Here’s the planned chart showing the project schedule for WordPress version 4.5.


WordPress core developer, Mike Schroder is the release lead for the version 4.5. He will be assisted by two other release deputies, Mel Choyce, and Adam Silverstein.

Announced at the latest core developer chat, Adam Silverstein will support as the release deputy and Mel Choyce as the design deputy for WordPress 4.5.

As you can see in the project schedule, all new enhancements and feature requests for the version 4.5 will need to be added by the release of Beta 1 version.

All the new features are first worked on as plugins and are decided to be merged in the core over the course of development.

I will surely come up with a post with the upcoming features in WordPress 4.5 then, but few features worth mentioning that are being worked on and also made it to discussions in the opening meeting include;

  • Improvements with customizer including customize pane resizer and customize device preview.
  • Improving Post Edit and Publishing process.
  • Improving the compression of images in core
  • HTTPs improvements to fix mixed content

Additionally, new features, worked on currently as plugins, that already look exciting to me include:


  • Shiny Updates – removing the ugly bits of updating plugins and themes.
  • WP Toolbar Experiments – some potential UX changes to the WordPress toolbar.
  • WordPress REST API (Version 2) – of course, the complete version of WordPress REST API we all have been waiting for!


You can see more of the feature plugins being developed here.

I am excited about the improved image compressions, HTTPs improvements and the Two-Factor Authentication for WordPress.

What features are you expecting and excited about in the WordPress 4.5? Let me know in the comments below.