WordPress is widely used in current website building. And backup is very important. This article will show you how to restore a WordPress website from a previous backup file.
- Login to your WordPress website admin console. And download the latest website backup file. I use the BackWPup WordPress plugin to create the website’s daily backup.
- So I click the BackWPup —> backups menu in the WordPress dashboard left panel to list all the backup files on the page right side.
- Click the Download link on the right side backup file row to download the backup file.
- After download, extract the zip file to a local folder. And then copy all the files in the folder to your local website root folder. My local website folder is
C:\xampp\htdocs\wordpress
. - Please note the .sql file in the unzipped folder, in my example, the .sql file is backwpup_13910f01_twothrp0_ss_dbnamedcb.sql. This file is the website database backup file. From the file name, we can see the database name is twothrp0_ss_dbnamedcb.
- Open a MySQL admin manager, I use SQLyog community version. Right-click left panel, click ” Create Database” menu to create database twothrp0_ss_dbnamedcb in it. Please Note the database charset should choose utf8 and database collation should choose utf8_bin.
- Right-click the database name, click ” Import —> Execute SQL scripts… ” to select the above database backup SQL file to execute.
- When execution complete, press F5 to refresh the left panel tree, you can see all backup tables and data that has been added to the database.
- Right-click wp_uhau_options table, click ” Open Table ” in the popup menu list. And change the siteurl and home column value to your local URL in the right panel. My local siteurl and home value is
http://localhost/wordpress/
. Do not forget to click the blue soft disk icon in the table data list top toolbar to save your update. - Open the wp-config.php file which saved in your local website root folder like
C:\xampp\htdocs\wordpress
in a text file editor. Get the database user name and password from the file like below.// ** MySQL settings - You can get this info from your web host ** // /** The name of the database for WordPress */ define( 'DB_NAME', 'db_name' ); /** MySQL database username */ define( 'DB_USER', 'db_user' ); /** MySQL database password */ define( 'DB_PASSWORD', 'db_password' ); /** MySQL hostname */ define( 'DB_HOST', 'db_host' ); /** Database Charset to use in creating database tables. */ define( 'DB_CHARSET', 'utf8' ); /** The Database Collate type. Don't change this if in doubt. */ define( 'DB_COLLATE', '' );
- Create a user account with the above username and password in MySQL server use SQLYog. Do not forget to assign all privileges for operating database twothrp0_ss_dbnamedcb to the user.
- Now open a web browser, browse URL http://localhost/wordpress/wp-admin, and log in to the admin console. If you see the error message Error establishing a database connection that means the database user privileges are not granted correctly.
- You should change the user Host to localhost and restart the MySQL server in XAMPP to make it take effect.
- Now login to the WordPress admin manager dashboard again.
- Click the ” Settings —> General ” menu in the left panel, do not edit any field, just click the ” Save Changes ” button on the page right side to save it.
- Click the ” Settings —> Permalink ” menu in the left panel, also do not edit any field, just click the ” Save Changes ” button on the page right side to save it.
- You can also change plugins or check WordPress update in the admin console.
- Now the restore WordPress website from backup file process completes successfully.
- Logout admin console, browse URL http://localhost/wordpress/, you can find your local website execute normally.