I have found myself in a situation, a couple of times, where I needed to manually change the WordPress URL in the database. Often it was a client that passed on the backup files to me and the address of the site had changed.

In this blog I am going to show you how to manually alter your WordPress database to change the WordPress site URL. This is used when a WordPress website needs to move over to a new domain (URL).

Please note that this is not the recommended method to change the WordPress URL when moving site’s over to a new domain.There is an array of plugins available for migrating WordPress websites such as WP Clone by Code Academy, Duplicator, WP Migrate DB Pro and more.

A great tip to remember is to backup your database every time before you do a direct database change.

What Tools You Will Need

Previously working in the website development industry for the past couple of years, I have had my fair share of transferring sites from my development environment over to my client’s live site. In most cases I used WP Migrate DB Pro which automatically does the rewrite for you.

  • Basic understanding of PHPMyAdmin or similar tool.
  • cPanel access. (Please note FTP access won’t work for this guide).
  • Time to complete: 5 – 10 minutes.

Change Your WordPress URL In The Database

Now that you have your website’s access details that is required for this guide, we can get into it! In this case, we will already restored our WordPress backup on the new domain using FTP or cPanel’s File Manager and we have imported the database backup and we need to do the final step in changing the WordPress website’s URL.

1. Navigate to your PHPMyAdmin of your website. This is usually done via cPanel or unique link. This may be provided by your hosting company.

PHPMyAdmin link in cPanel

PHPMyAdmin link in cPanel.

2. Once inside your PHPMyAdmin editor, select the SQL tab, a text area will appear that will allow you to enter SQL code.

SQL Query in PHPMyAdmin Example

SQL Query in PHPMyAdmin Example

3. Apply the following code and select Simulate query. This will first see what rows are affected and ensure’s that your SQL code is correct. This is good practice before running a SQL query on a site.

Please note that you will need to adjust the prefix wp_ to match those of your database you are editing. This is the default prefix used.

4. If all is well from the Simulate query then you can select Go which runs the SQL code on your database.

Simulate Query Results

Simulate Query Results

5. That’s it, you’re done. If all is correct your site will be working as intended.


Now that you’ve learnt how to change the WordPress URL in the database, you are able to transfer sites to your local environment for testing purposes or even to a new domain. I recommend in using any of the plugins mentioned in this post before using this method as it’s not the best practice and I cannot express that enough. This guide is meant to be for a worst case scenario in moving a site to a new domain for whatever reason. I hope it’s been helpful.