Call 02380 004 154

Email [email protected]

How to update your WordPress URL from PHPMyAdmin

Posted on 16 February 2022

Sometimes we’ll run into a site that has had it’s domain updated but before the previous domain expired the website wasn’t updated to the new domain. We’ve also run into websites that have been partially migrated from a staging setup to production where a backup has been used instead of transfer. This has meant the domain has stayed the same and the site can no longer be accessed.

The best way to update your domain is through wp-admin if you can. If you’ve tried everything you can with regards to getting into wp-admin with no joy – there is another way.

The Solution

The only working solution to the following so far that we have found is to update the URL from within PHPMyAdmin. There are a number of fields where this URL needs to be updated. Fortunately. With the folllowing piece of code you can update the URL.

phpmyadmin

Getting to PHPMyAdmin

To enter the code you need to get to PHPMyAdmin. There may be specific steps to do this depending on your web host but if you’re using cPanel then it should be as follows.

  • Sign into your web host account
  • Go to cPanel
  • Scroll down and open the PHPMyAdmin link (under databases)
  • Select the WordPress database
  • Enter the following code
UPDATE wp_options SET option_value = replace(option_value, 'oldurl.com', 'newurl.com') WHERE option_name = 'home' OR option_name = 'siteurl';UPDATE wp_posts SET guid = replace(guid, 'oldurl.com','newurl.com');UPDATE wp_posts SET post_content = replace(post_content, 'oldurl.com', 'newurl.com');

UPDATE wp_postmeta SET meta_value = replace(meta_value,'oldurl.com','newurl.com');

With the above you’ll need to update oldurl.com to the url the site was using. You will then need to update newurl.com to the url you want the site to be using. You don’t need to include http:// or https:// but you should make sure you’re using www. or not at the start of your domain. Good luck!

The above code will also work via software like toad if you can’t access PHPMyAdmin but you’ve got access to your MySQL database with that.

The above code comes with no warranty.

Share this post with your friends, followers and connections!


Subscribe to our mailing list

* indicates required

View previous campaigns.