Change wordpress URL via command line (cli)
If you moved your wordpress installation to another location/ server of maybe you want to restore from backup an older wordpress installation or for whatever reason you want to change the URL of an existing wordpress installation, this is how you can achieve this through command line (cli):
Let’s say the current URL of your wordpress installation is yolobefree.com and you want to move this wordpress instance to kb.yolobefree.com. First, you need to login in mysql and select the database:
mysql -u root -p
use yolobefree_db;
First, check your database entry for the current URL:
select * from wp_options where option_value="https://yolobefree.com";
Then update the database entry with the new URL:
update wp_options set option_value ="https://kb.yolobefree.com" where option_value="https://yolobefree.com";
Now you should be able to see your new URL in place. In this case, you should be able to point your browser at https://kb.yolobefree.com