BLACK FRIDAY SALE IS LIVE !!!!!

Need Assistance?

In only two hours, with an average response time of 15 minutes, our expert will have your problem sorted out.

Server Trouble?

For a single, all-inclusive fee, we guarantee the continuous reliability, safety, and blazing speed of your servers.

How To Change the WordPress Site URL In Database using Command-line

Most of us are familiar with WordPress domains. WordPress uses MySQL database to store its data including its site and home URLs. In some cases, we need to change the WordPress site URL in the database also.

For example, while we doing the migration of WordPress sites from one server to another server, we need to change the old WordPress site URL in the MySQL database to the new one.

We can add the home and site URL of WordPress using the wp-config.php file. But it is relevant to change the site URL in the database.

Steps for changing the WordPress Site URL in the database using CLI

We can find your WordPress domain’s database details from wp-config.php file.

This file will be located in the document root of your domain.

You can follow the given steps to change the WordPress URLs including the WordPress site URL in the MySQL database.

  • Log into the Mysql prompt.
mysql -u root -p
password:
  • Select your WordPress database.
mysql > show databases;
mysql > use wordpress_db;
  • Chnage the WordPress URLs in the database using the given commands.
MariaDB [wordpress_db]> UPDATE wp_options SET option_value = replace(option_value, 'https://old_wordpress_url', 'https://new_wordpress_url') WHERE option_name = 'home' OR option_name = 'siteurl';


MariaDB [wordpress_db]> UPDATE wp_posts SET guid = replace(guid, 'https://old_wordpress_url','https://new_wordpress_url');

MariaDB [wordpress_db]> UPDATE wp_posts SET post_content = replace(post_content, 'https://old_wordpress_url', 'https://new_wordpress_url');

MariaDB [wordpress_db]> UPDATE wp_postmeta SET meta_value = replace(meta_value,'https://old_wordpress_url','https://new_wordpress_url');

You can replace the old_wordpress_url and new_wordpress_url with your WordPress URLs.

now you can able to access the WordPress site using the new updated URL.

You can also change the home and site URL of WordPress using the wp_options table through the PhpMyAdmin.

If you are still getting errors while updating the WordPress URLs, OUR technical team will help you to resolve the issue within a short period.

Liked!! Share the post.

Get Support right now!

Start server management with our 24x7 monitoring and active support team

Can't get what you are looking for?

Available 24x7 for emergency support.