Keeping a backup copy of your website can save a lot of aggravation down the road. It’s better to be prepared in the event of a catastrophe. But what if you only have a backup of the database?
Not everyone keeps complete backups on hand. And if something drastic happens on your server, you could lose everything.
So, what can you do to restore a WordPress database?
In this tutorial, I’ll show you how to restore the website from a database backup in WordPress.
Restoring a WordPress Database
Ideally, you would want a complete backup to quickly get the site back up and running. In this instance, it’s better to use UpdraftPlus.
But let’s say that the website was completely destroyed and you only have the SQL database file saved to your computer.
Create a New Database
We’ll need to start by creating a new database on your server. This will give you a location for which to import the data you’ll use.
Click MySQL Databases from the cPanel dashboard.
Give the database a new name. This is the name of the database you’ll use when you reinstall WordPress. I’m simply going to name it, «wpdb007.»
Take note of the prefix of the database name. You will need this to connect your website. It may look something like, «test_.» You will need the text and the underscore before the database name.
So, the name as a whole would look kind of like, «test_wpdb007.»
Click the «Create Database» Button. This will save the empty file to your web hosting server.
Once the database is created, click the link to «Go Back.» This will take you back to the MySQL Database page.
Create a New User
To recover a deleted WordPress site from a backup of the old database, you need a new user. This is the login information that lets WordPress connect to the new database. Without it, the website won’t have access to the information.
Scroll down to the «Add New User» section of the page.
Input a new username, password and click, «Create User.»
It’s probably a good idea to write down these credentials for when you reinstall WordPress. It’ll make it easier to remember the log in information. And don’t forget to take note of the prefix to the username.
It should be the same as the database.
Add User to Database
Scroll down to «Add User to Database.» You need to make sure WordPress can connect to the site with this account.
Use the drop down boxes to select your user and database.
Click the «Add» button.
On the next screen, click the box for «All Privileges.» This will give WordPress full access to the database.
Click the «Make Changes» button on the bottom.
The account is now ready for WordPress to use it.
Importing the Website Database Backup for WordPress
Now that we have an empty database ready to go, it’s time to upload the file.
Go back to cPanel and click «phpMyAdmin».
Find your database in the list and click it.
Click the «Import» option from the top toolbar.
Click the «Choose File» button and select the database from your computer.
Make sure the Format is set to SQL and click, «Go.»
After a few moments, the database will be ready. How long this takes is dependent on a few factors. For example, database size and Internet upload speeds will affect the amount of time it takes to import.
Adding the Database to Restore the Website
With the database filled and ready to go, it’s time to add it to WordPress.
Now, you’ll have a couple of ways to install the content management system. You can use easy methods, such as installing WordPress with Softaculous. However, some people like to install WordPress manually.
Unfortunately, Softwaculous does not have the ability to use an existing database when setting up WordPress. It only works for new sites with unique databases.
When installing WordPress manually, you’ll come to a page for the database. Input the database and credentials of the account you created earlier.
Once you click «Submit,» you’ll get a message stating WordPress is already installed. This is normal.
All you need to do now is click the «Log In» button and access your website normally.
Restoring the Rest of the Site
Unfortunately, the database doesn’t hold some of the other nuances you might have had on your site. Things like plugins, images and themes will need to be added again.
However, you might be able to search your browser’s cache for some of those images or retrieve them through a cache of your site on search engines.
This is one of the reasons why I suggest using plugins like UpdraftPlus or other backup tools. You won’t have to worry about trying to find all of these elements.
And there are plenty of plugins to choose from for creating a complete save of your site.
It simply makes recovering deleted WordPress sites easy from a backup.
Never Underestimate Redundancy
Having a backup on hand saves a great deal of trouble, lost traffic and possibly lost income. Don’t wait too long to have a proper method for creating copies of the site. Whether it’s a server crash, hackers or malware, not having a quick and easy plan can prove to be devastating.
What kind of backup methods do you have in place? Do you find it useful to backup files to the Cloud?
Author: Michael Brockbank
Michael has been in the tech industry in some form or another since the late 1990s. He’s built a variety of websites using HTML, Joomla and WordPress. Starting his freelance writing career in 2012, he’s completed thousands of projects world-wide covering a wide scope of topics. Michael is currently the Content Marketing Team Lead. Today, he manages a team of writers to create tutorials, blog posts and support content for customers. Outside of GreenGeeks, he manages a YouTube channel that helps others learn how to become freelance writers, bloggers and overall professionals.