How to Change the WordPress site URL using MySQL command line

In this case, We would like to share the common issue how to change the main URL in WordPress when you are going to migrate your staging into production site or change the domain name.

Solution: Use the command line to make short work of the task.

$ mysql
$ use database_name;
$ show tables;

You will see something like this:

 +————+————+————+—————+—————+
 | Tables_in_database |
 +————+————+————+—————+—————+
 | wp_commentmeta           |
 | wp_comments              |
 | wp_links                 |
 | wp_options               |
 | wp_postmeta              |
 | wp_posts                 |
 | wp_term_relationships    |
 | wp_term_taxonomy         |
 | wp_terms                 |
 | wp_usermeta              |
 | wp_users                 |
 +————+————+————+—————+—————+
 11 rows in set (0.00 sec)
mysql> SELECT * from wp_options WHERE option_name = 'home' OR option_name = 'siteurl';
mysql> UPDATE wp_options SET option_value = http://www.domain_name WHERE option_name = 'home' OR option_name = 'siteurl';

Now your domain should work perfectly.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.