Changing WordPress URLs in MySQL Database

WordPress stores the MySQL database names and their credentials in the wp-config.php file. You can find this file in your root file directory:

  1. Access your hPanel and open File Manager.
  2. Select the domain name, then click Go to File Manager
  3. Open wp-config.php and search for DB_NAME. The value of this parameter is your database name. For instance, the name of our MySQL database is u123456789_gagap.

To replace your current URL, follow these steps:

  1. Go to phpMyAdmin via your website’s control panel.
  2. The left panel lists all of your databases. Select the one connected to your WordPress site and head to the SQL tab.

Enter the following SQL query:

UPDATE wp_options SET option_value = replace(option_value, '', '') WHERE option_name = 'home' OR option_name = 'siteurl';

UPDATE wp_posts SET guid = replace(guid, '','');

UPDATE wp_posts SET post_content = replace(post_content, '', '');

UPDATE wp_postmeta SET meta_value = replace(meta_value,'','');

Replace with your current WordPress address and with your new WordPress address.

Press Go. You will see success messages along with the number of changed rows. Note that the number of rows will be different for each WordPress website.

The last thing we need to do is verify the changes. Open the wp_options table and check the option_value ofsiteurl and home. You should see your new URL.

Leave a Reply

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