WordPress depends on the MySQL database for storing its data, which encompasses site URLs. Should you find the need to alter your WordPress URL, adjustments within the MySQL database become necessary. This guide aims to walk you through the process, so continue reading to acquire the knowledge of how to execute it.
Changing WordPress URLs in MySQL Database
To replace your current URL, follow these steps:
- Navigate to phpMyAdmin through your website’s control panel.
- On the left panel, you’ll find a list of all your databases. Choose the one associated with your WordPress site and proceed to the SQL tab.
- Enter the following SQL query:
UPDATE wp_options SET option_value = replace(option_value, 'oldurl.com', 'newurl.com') WHERE option_name = 'home' OR option_name = 'siteurl';UPDATE wp_posts SET guid = replace(guid, 'oldurl.com','newurl.com');UPDATE wp_posts SET post_content = replace(post_content, 'oldurl.com', 'newurl.com'); UPDATE wp_postmeta SET meta_value = replace(meta_value,'oldurl.com','newurl.com');
SQL- Substitute oldurl.com with your existing WordPress address and newurl.com with your updated WordPress address.
- Also check for the prefix you are using for website wp_ . Replace it with your database prefix.
- Click on Go. Success messages will appear, accompanied by the count of modified rows. It’s important to note that the number of rows may vary for each WordPress website.
- The final step involves verifying the changes. Access the wp_options table and inspect the option_value of siteurl and home. Your new URL should be visible.
- If you encounter error messages and the queries fail to execute, review your code for syntax errors and ensure the correct table prefix is being used. If the error persists, reach out to hosting support for further assistance.