Many web hosting packages, including those of GoDaddy, include an installation of phpMyAdmin that you can use to manage your databases. phpMyAdmin makes tasks common tasks like creating tables, inserting and deleting rows, and most importantly, backing up and restoring your databases.
In this tutorial we’re going to look at the simple process of creating a backup of WordPress database and then restoring it.
Step 1: Creating a Backup of your WordPress Database
After logging into phpMyAdmin, the first thing you’ll need the know is the name of your WordPress database – you’ll have most likely chosen this name during installation, and tt often has a prefix of “wp_”.
If you open phpMyAdmin to find that you have several databases and aren’t sure which one is your WordPress database, you can find the name of the database in your wp-config.php file, which will be in the root directory of your WordPress installation. It’ll be surrounded by single quotes on a line toward the top of the file that looks like this: <code>define(‘DB_NAME’,'database_name’);</code>, where database_name is the name of your database.
After you’re sure which database you want to export, click the “Export” tab located toward the top-right of your screen.
You’ll then be presented with the list of databases you have. Select the one with your WordPress database name. Normally the default export options are fine, but just to be sure, here are some of the settings you want to make sure are checked.
- Below the list of databases, choose SQL as the export format. This will make it much easier to import, as you won’t have to worry about things like delimiters like you would if you chose something like the CSV format
- Double-check that the Export type is INSERT (this will be explained when restoring the database).
- Make sure that “Add DROP DATABASE” and “Add DROP TABLE / VIEW / PROCEDURE / FUNCTION” are not selected.
Saving the File
Now that the settings are okay, scroll down to the bottom of the export page and select “Save as file” and enter a file name. Any name is fine, and you don’t need to add a file extension, phpMyAdmin will do that for you.
If you have a large database (perhaps more than a few dozen posts and comments, you’ll want to choose “gzipped” as your compression type. Otherwise, you set compression to “none”. It’s important that you choose one of those two options and not the regular “zipped” option, because most versions of phpMyAdmin aren’t able to import .zip files, but can import files that have been compressed using GZIP.
Now, click “Go” and wait. The larger your database the longer it’ll take, but in general it won’t take more than several seconds. You’ll then see the dialog box asking you to save the file to your computer, choose a location that will be safe and you’ll remember. It doesn’t hurt to do this often, especially if you really value the content of your blog.
Step 2: Restoring your WordPress Database
Since you’ve created a complete backup of your database, importing it is going to be an incredibly fast and simple operation.
First, you’ll need to completely delete your old database. There are a couple of ways to do this depending on your version of phpMyAdmin. The easiest and most reliable way that will apply no matter your version is using the SQL’s “DROP” command.
Go to the root of phpMyAdmin by clicking on the phpMyAdmin logo in the left pane (it’ll be above your list of databases), then click the “SQL” tab. In the large textarea paste the following code <code>CREATE DATABASE your_wordpress_database;</code> and replace your_wordpress_database with the name of your own.
If you get an error about not having the permissions to perform a DROP, you may have to delete the database through your control panel (i.e. cPanel).
Once your database has been deleted, click the “Import” tab. Once the import page loads, click the “Browse” button and navigate to the location on your hard drive where you saved your WordPress backup and select it. Now click “Go”.
It should be as simple as that! If you have any questions feel free to leave a comment and I can guide you through your problem.