Change and Update WordPress URL's in the Database

After moving your WordPress site to a new URL, the new URL's in the MySQL database will need to be updated in the MySQL tables.  This can be updated via phpMyAdmin.

To update via phpMyAdmin: 

- Login to your cPanel account

- Click on the phpMyAdmin icon under the database section.

- Once phpMyAdmin loads, select the WordPress database.

- Select the SQL tab on the right hand side of the screen and enter the following, replacing oldurl with the old URL you were using and newurl with the new URL you are wanting to use*:

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');


Notes:

If the table prefix is different than wp_, this will need to be updated.
There will be no trailing stashes added to the code

* If you are unsure on what to replace the values with, you can use the following code generator:
https://codepen.io/EightArmsHQ/full/nzEjI

  • wordpress
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How to reset your WordPress administrator login

There are two methods to reset your WordPress Administrator Login. 1.  Resetting from the...