Importing a SQL file with your WordPress data

Migrate to WordPress

Data, such as pages, posts, comments, forum threads and users of your new WP site generated during the migration is safely stored in a SQL file.
To retrieve all such data into your WordPress dashboard, you have only to import the SQL file in your WordPress database.

To import this file you can choose between two options:

  • From Outside WP, through any database import tool, as for example PHPMyAdmin .This is the way we recommend most.
  • From Within WP, through one of the (few) available restore modules.

Let’s see both options.

First option: From outside WordPress through PHPMyAdmin.

PHPMyAdmin is an easy and free tool to correctly manage MySQL databases and it also is the official database backend for WP. This tool is available on your control panel. Once you are inside the tool PHPMyAdmin select the files of the wordpress database that you find on the left column. If your site contains several databases and you´re not sure which one is the one WP is installed on, open wp-config.php and look for a sentence like define(‘DB_NAME’, ‘this is the name of your database’).

After selecting the database just go the import tab and select the SQL file to import.

admin-import wordpress SQL file

Second Option: From within WP through Adminer plug-in

An alternative option is to install a WordPress plug-in that allows us to select and execute a SQL file from within the WP dashboard. For this our recommendation is to install the Adminer plug-in (WordPress version of the Adminer tool, kind of a competitor of phpmyadmin (as the Adminer people say in their web page: “Replace phpMyAdmin by Adminer and you will get tidier user interface, better support for MySQL features, higher performance and more security.”).

Once installed, you’ll find the Adminer option under the Tools Menu. Once you click on it you’ll have the option to execute Adminer in a separate tab

adminer php mysql tool

and the Adminer interface will immediately pop up. As with phpmyadmin, you have the list of tables on the left. The right hand side show the data/structure of the selected table.

Select wordpress terms from the panel

In the upper left corner, you’ll see the two most important options, the DUMP button (to export the data of the database) and, the option we were looking for, SQL command (to execute a SQL sentence, possibly importing it from an external file). Upload here your file and Adminer will take care of executing all SQL commands in it.

import sql adminer

Another option would be to use a Backup&Restore plug-in (perhaps surprisingly, the number of plug-ins for doing backup largely outnumbers the number of plug-ins that can also restore the database from a backup file). Among the few plug-ins that offer a Restore feature we have WP-DB ManagerXcloner and UpdraftPlus  (our favourite one, BackWPup recently stopped offering the restore feature).

We hope you’ll find this information useful. If something is not clear or missing, please let us know and we will improve the explanation.

Posted in: Content export / import migratetowpImporting a SQL file with your WordPress data