How to Find and Replace URLs in a WordPress Database Using phpMyAdmin
Technical changes in your website might be needed to keep up with the demands of your business. One of these changes might be changing your WordPress website’s URL. This is a major change, however, because it significantly affects your whole backend system.
There are many reasons why you would like to change your URL. One common reason is you might be changing your line of business and acquiring a new domain name. Regardless, you must do all the changes appropriately to keep your website functioning well. In this article, we will give you a guide to find and replace URLS in a WordPress database correctly.
What Is MySQL Database and Why Is It Important?
MySQL is an open-source database management system that utilizes structured query language (SQL). It is used by WordPress to keep its files, so it plays an important role in changing your URL. SQL is a programming language for managing, accessing, and adding content within a database. What is interesting about this programming language is it is reliable, flexible and easy to use, and processes quickly.
Steps to Find and Replace URLs in a WordPress Database Using phpMyAdmin
Now that you know what MySQL database is and why it is important, it is time we proceed to the steps to change URLs.
Step 1: Identify the Name of Your MySQL Database
In owning a WordPress website, you can have multiple MySQL databases. Proceed to the next step if you only have one. You must know the name of the database you want to make changes for, so you can make modifications properly.
To find the name of the database, you can see it in your wp-config.php file. To locate the file, you must log in to your control panel and select File Manager under the Files section.
Open your public_html directory and look for the file. Once you see it, right click on the file and select Edit.
On the edit page, find DB_NAME. You will see a value indicated on the DB_NAME tag, and that is the name of your database.
Step 2: Change WordPress URLs
The process of changing your URL is easy, and what you need is your WordPress phpMyAdmin. You can see this in your control panel as well.
Go back to the main page of your control panel and type phpMyAdmin in the search box. Click the icon for it when you see it on the results page.
Once you are inside, look for the name of your database on the left side of the page. Click your database once you see it and go to your SQL tab on the right side of the page. Copy and paste this SQL query there:
<!-- wp:paragraph --> <p>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');</p> <!-- /wp:paragraph --> <!-- wp:paragraph --> <p>UPDATE wp_postmeta SET meta_value = replace(meta_value,'oldurl.com','newurl.com');</p> <!-- /wp:paragraph -->
Replace all oldurl.com you see in the query with your existing URL. Also, replace all newurl.com with your new URL. Click Go at the bottom ride side of the page.
You will then see messages that the change was successful with multiple rows. You can verify the change you made as well. Go to your wp_options on the left side of your screen and look for home and siteurl on the right side of the page. You should see your new URL listed under option_value.
The steps to find and replace URLs in a WordPress database is easy and short. You only need to know the name of your URL database before proceeding to changing it completely. Follow our guide now and make the changes worry-free!