Changing the URL of your WordPress site may be necessary during website migration or when transitioning from a development environment to a live server. This tutorial will guide you through the process of changing WordPress URLs in the MySQL database using phpMyAdmin. Follow these steps carefully to ensure a smooth transition.
Step 1: Determine the Name of Your WordPress MySQL Database
Before making any changes, you need to identify the name of your WordPress MySQL database. This information is crucial for accessing the correct database in phpMyAdmin.
- Login to your hosting control panel.
- Locate and access the “Database” or “MySQL Databases” section.
- Look for the database associated with your WordPress installation. Make note of the database name.
OR
- Login to your hosting control panel.
- Open File Manager.
- Open wp-config.php and search for DB_NAME. The value of this parameter is your database name.
Step 2: Open phpMyAdmin and Navigate to the WordPress Database
Once you have the database name, it’s time to open phpMyAdmin and locate the WordPress database.
- Log in to your hosting account.
- Find and open phpMyAdmin from the control panel.
- On the left-hand side, you’ll see a list of databases. Click on the database corresponding to your WordPress site.
Step 3: Changing WordPress URLs in MySQL Database via Query or Table Update
Now that you are in the correct database, you can proceed with changing the URLs.
Option 1: Using SQL Queries
- Navigate to the “SQL” tab in phpMyAdmin.
- Execute the following SQL queries, replacing `oldurl.com` and `newurl.com` with your old and new URLs:
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');
Important! Your table prefix might not be wp_. See the correct table prefix on the left panel of phpMyAdmin, and update the SQL query.
Click “Go” to execute the queries.
Option 2: Update URLs Manually in wp_options Table
- Click on the “wp_options” table.
- Look for rows with the “option_name” values “siteurl” and “home.”
- Click the “Edit” button for each of these rows.
- Update the “option_value” field with your new URL.
- Click “Go” to save the changes.
Conclusion:
Congratulations! You have successfully changed the WordPress URLs in the MySQL database using phpMyAdmin. Make sure to test your site thoroughly to ensure all links and resources are loading correctly with the new URL.
Note: Always perform a backup before making any changes to your database to avoid potential data loss.