- These instructions were created with a cPanel-based server in mind.
- Command line access via SSH will be necessary to follow along.
- The server must have WP-CLI installed, for installation directions see this tutorial.
Restore a Database:
- Login to the server via SSH as the cPanel user that owns the domain, or the root user.
ssh firstname.lastname@example.orgIn the example we are using ssh to connect to the server. You can follow the rest of the steps even if you connect via alternative means(TTY, a Windows SSH Gui, etc).If you login as root you will need to use `su` to take on the user which owns the WordPress site before you continue.
- Now logged in (as the cPanel user) change to the WordPress root folder:
cd ~/public_htmlWe’re using a cPanel server so we know WordPress should be installed in the `public_html` folder. If you are not on a cPanel server it will be in a different location.
- Once in the WordPress root folder (where you can find wp-config.php) you can use the wp-cli tool. To restore your database run one of the following command:
wp db import ../my_wordpress_db.sql
Success: Imported to ‘../my_wordpress_db.sql’.Seeing the text above confirms your WordPress database has been restored. You should now double check that everything is loading correctly and verify that the restore fixed what you were hoping.