Making a backup of your website’s files and databases is always a good idea. The more backups you make – the bigger chance you’ll suffer fewer consequences from unpredictable events. Whether you removed some files accidentally by yourself or your WordPress got compromised and your files were corrupted by malware, it may still be possible to restore your WordPress site. In this tutorial, you will learn how to restore WordPress, even if you have only a MySQL database backup.
This method of recovery is only partial and you might not be able to recover everything, however, WordPress stores most settings and data in its database. Thus, you will be able to recover most of your WordPress website only from your database.
What you’ll need
Before you begin this guide, you’ll need the following:
- Access to your hosting control panel
- MySQL database backup
Step 1 – Importing WordPress Database Backup
First of all, we need to create an empty MySQL database. We will Import our MySQL database backup to it.
- Access the hosting control panel and find your MySQL Databases management menu.
- Create a database and assign a user to it. In this example, Hostinger control panel offers the ability to create MySQL databases with users assigned to them very quickly, we only need to fill out the required information. Check out this guide, if you are using cPanel to manage your account.
- Access your newly created database via phpMyAdmin.
- Import the database you’ve saved from your previous WordPress installation. You can do this on Import section: simply select the .SQL file (1), set format to SQL (2) and press the Go button (3). A detailed tutorial about how to use phpMyAdmin’s import feature can be found here.
IMPORTANT: Write down the MySQL database details: database name, user and password, as you will need them in the next step. Also, write down the Table Prefix. You can see the Table Prefix on the left side of phpMyAdmin.
Step 2 – Restoring WordPress
Since you only have a MySQL database at the moment, the next step should be installing a fresh WordPress instance:
- Download the WordPress installation files from here.
- Upload the WordPress files to your hosting account. If you are not sure how to do this, check a detailed guide on how to install WordPress here.
- Access your WordPress installation (by accessing your website with your browser) and choose a language for the WordPress installation. Once you select the language for your site, hit Let’s go! and you will continue to the database configuration step. Use the information of the database you’ve just previously created.
- If done correctly, at the end of the installation, you will see a message that WordPress is already installed.
IMPORTANT: If you did not receive this notification, you might need to re-do the whole process. Double-check your Prefix setting.
Step 3 – Re-installing your Theme and Plugins
At this point, your website should have your old posts and pages, settings, custom CSS files, users. However, without your previous themes and plugins, all of this will not appear as it did before:
- The first thing you should do is re-install your theme. Simply install the same theme that you’ve used as your default one before. Make sure to check out this guide as a reminder on how to easily install WordPress themes.
- Now re-install your previously installed plugins. Fortunately, your database had a list of previously installed and activated plugins, so when you access your plugins menu, you will see a list of plugins that are currently missing.
Step 4 – Fixing Permalinks
Now that you’ve regained most of your website, you might still experience issues with it. Most likely, your Permalinks won’t be working as they were and navigating on your website will result in a 404 Page Not Found error.
You can quickly fix your Permalinks by clicking on Settings on your Dashboard and accessing your Permalinks section. Click Save Changes at the bottom, without actually making any changes. This should refresh permalinks and fix them.
Step 5 – Fixing Missing Images
Now comes the hard part. Unfortunately, your database did not contain images from your previous website. There is no easy way to fix this issue. You will need to re-upload each and every image that is missing.
To help you find which images specifically are missing, we will be using the Broken Link Checker plugin.
- Just like with most plugins for WordPress, you can install it via the official plugin repository through your WordPress admin area. Simply click on Plugins in your Dashboard and select Add New. Enter Broken Link Checker in the Search Bar and install the plugin. Make sure you activate the newly installed plugin.
- Access your newly installed plugin via the Dashboard by clicking on Tools and accessing Broken Links. You will see a list of broken/missing links, so this will help you determine which images are missing and their previous location.
- Now simply reupload the missing images and, if necessary, update their links.
The most unfortunate situation is when you no longer have those images. In this case, the best solution is checking an archived version of your website. Archive.org is a great tool for such cases and it might have a previous, fully working version of your website. You will be able to download the missing images from there:
- Access Archive.org. At the top of the page you will see the “Waybackmachine”. Enter your website’s URL and hit ENTER key.
- If there are any snapshots available of your website, you will see these blue circles around certain dates of the year. Click on those dates in order to access a previous version of your website.
- After that, search for the specific images that are missing and download them from the archived version.
Now you know how to easily restore most of your WordPress installation only from a backup. You also know how to detect additional issues, such as broken links or missing images and a great trick in order to recover them if you no longer possess those images. Make sure to start making backups of your website in order to avoid any issues if your website gets lost or removed.