How to Restore a WordPress Website Locally or Online | phpMyAdmin + SQL

Restore a WordPress Website

Allow me to guide you on how to Restore a WordPress website using the WordPress files and SQL database, which is a common process for developers and website owners. In this guide, I will show you step-by-step how to connect your website files and database, whether you’re working locally or online. Let’s dive in!

What You Need

To get started, you’ll need:

  1. A backup of your WordPress files.
  2. A SQL database file.
  3. A server environment, such as XAMPP for local setups.
  4. Access to phpMyAdmin to manage your database.

This guide works for both local and online environments as long as phpMyAdmin is available.

Need Reliable Hosting for Your WordPress Website?

Host your site with Hostinger for lightning-fast speeds, top-tier security, and 24/7 support—all at an unbeatable price!

Step 1: Prepare Your WordPress Files

First, open your server environment (in this example, XAMPP). Navigate to the htdocs folder within your XAMPP installation. Create a new folder—you can name it something relevant to your project, like cvservices.

Copy all your WordPress files into this newly created folder. These files should already be backed up and ready to use.

Step 2: Prepare Your Database

Make sure you have a backup of your SQL database file. This file is typically provided by your hosting provider. Check that it is complete and has the correct size to avoid import errors.

Step 3: Create a Database in phpMyAdmin

  1. Open your XAMPP control panel and click on “Admin” to access phpMyAdmin.
  2. Click on the “Databases” tab and create a new database. For example, name it cv_data.
  3. Copy this database name for later use.

Step 4: Import the SQL File

  1. Select the newly created database in phpMyAdmin.
  2. Go to the “Import” tab.
  3. Click “Choose File” and locate your SQL file.
  4. Click “Go” to import the database. Check for errors during the import process. A green success message means everything is working as expected.

Step 5: Configure wp-config.php

Navigate to the folder where your WordPress files are stored and locate the wp-config.php file. Open it in a text editor, such as VS Code.

Update the following details:

  • Database Name: Replace the current database name with the one you just created (e.g., cv_data).
  • Database User: For local setups, the default is usually root.
  • Database Password: Leave this blank if no password is set for the local database.
  • Host: Ensure it’s set to localhost.

Save the changes to wp-config.php.

Step 6: Update URLs in the Database

Since the database still has the old URL references, you’ll need to update them to reflect your local or new environment.

  1. Go back to phpMyAdmin and select your database.
  2. Run the following SQL query to replace the old URL with your localhost URL:
  3. Replace https://cv.mbonisi.com with your old URL and http://localhost/_cvservices with your local URL.
  4. Click “Go” to execute the query. Confirm the changes have been applied.
-- Update siteurl in wp_options
UPDATE wp_options 
SET option_value = REPLACE(option_value, 'https://cv.mbonisi.com', 'http://localhost/_cvservices/') 
WHERE option_name = 'siteurl';

-- Update home in wp_options
UPDATE wp_options 
SET option_value = REPLACE(option_value, 'https://cv.mbonisi.com', 'http://localhost/_cvservices/') 
WHERE option_name = 'home';

-- Update URLs in wp_posts
UPDATE wp_posts 
SET guid = REPLACE(guid, 'https://cv.mbonisi.com', 'http://localhost/_cvservices/');

-- Update URLs in post content
UPDATE wp_posts 
SET post_content = REPLACE(post_content, 'https://cv.mbonisi.com', 'http://localhost/_cvservices/');

-- Update URLs in wp_postmeta
UPDATE wp_postmeta 
SET meta_value = REPLACE(meta_value, 'https://cv.mbonisi.com', 'http://localhost/_cvservices/');

Step 7: Test Your Website

Open your browser and go to http://localhost/_cvservices. Your website should now be accessible. If the design looks odd, it might be because some plugins or themes require updates.

Final Thoughts

Restoring a WordPress site locally or online is a straightforward process when you follow these steps. By managing your files and database carefully, you can ensure your website runs smoothly in its new environment.

If you’re looking for reliable and affordable hosting for your WordPress site, check out Hostinger. Their fast and secure servers make WordPress hosting a breeze.


Let me know how your restoration process went or if you have any questions! Don’t forget to like, share, and subscribe for more tutorials.

Leave a Comment

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