Change the WordPress site URL using MySQL command line

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

$ mysql
mysql > use database_name;
mysql > 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

mysq1 > SELECT option_name FROM wp_options;

Here you should see a list of all of the columns in wp_options. The ones we are interested in are “home” and “siteurl”.

mysql > SELECT * FROM wp_options WHERE option_name = ‘home’;

+———–+————-+———————————-+———-+
| option_id | option_name | option_value | autoload |
+———–+————-+———————————-+———-+
| 16048 | siteurl | https://zenhabits.net | yes |
+———–+————-+———————————-+———-+

mysql > UPDATE wp_options SET option_value=”https://zennewlife.com” WHERE option_name = “home”;

mysql > SELECT * FROM wp_options WHERE option_name = ‘siteurl’;

mysql > UPDATE wp_options SET option_value=”https://zennewlife.com” WHERE option_name = “siteurl”;

Once the above changes have been made, you should once again be able to access your WordPress login page.

Leave a Comment

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