Import MySQL Database

In MyKinsta, you can restore a backup that is a complete snapshot of your site’s environment (including files, database, redirects, and Nginx configuration). If you want to restore or import only your site’s database, this guide will show you a couple of different ways to do that.

This tutorial assumes you already have a backup or exported *.sql file, which you will be importing. If not, see our guide: How to Create a Database Backup.

These instructions are for importing a database backup of a site hosted at Kinsta. If you’re trying to import a database as part of a migration to Kinsta, check out our guide on Migrating Your Site to Kinsta.

Restore a MySQL Database Using phpMyAdmin

phpMyAdmin is a database management tool you can use to view, import, and export data in and out of your database.

  1. Log in to MyKinsta, go to WordPress Sites and select your site in the list.
  2. On the Info tab, scroll down to Database access. Click on the Open phpMyAdmin link, which will open phpMyAdmin in a new tab in your browser.
    Open phpMyAdmin from MyKinsta.
    Open phpMyAdmin from MyKinsta.
  3. Log in to phpMyAdmin with the Database username and Database password shown in MyKinsta.
  4. Before importing your database, making sure the existing database is empty is recommended to prevent possible duplication of data. To do that:
    1. Click on your database name.
    2. Scroll down if necessary and check the box next to Check all to select all of your database tables.
    3. In the dropdown menu next to that, select Drop.
    4. On the next page, confirm the DROP TABLE query by clicking Yes.
    Drop tables in phpMyAdmin.
    Drop tables in phpMyAdmin.
    Confirm you want to run the query to drop tables in phpMyAdmin.
    Confirm you want to run the query to drop tables in phpMyAdmin.
  5. Click on the Import tab and then click the Choose file/Browse button. Select your *.sql file, scroll down, and click Go.
    Select your .sql file to import in phpMyAdmin.
    Select your .sql file to import in phpMyAdmin.

Restore a MySQL Database Using WP-CLI

If your database file is larger than 134 MB, or you’d prefer to use the command line, you can use WP-CLI to restore your database instead.

  1. Connect to your site with SFTP and go to the public directory.
  2. Upload your database file.
  3. Connect to your server with SSH and navigate to the public directory:
    cd public
  4. Before importing your database, making sure the existing database is empty is recommended to prevent possible data duplication. The following command does that, so you have an empty database to import to (the --yes flag answers the confirmation message without a separate prompt):
    wp db reset --yes
  5. Import your database file (replace db-backup-name.sql with the actual file name):
    wp db import db-backup-name.sql
  6. Once your database is imported, delete the database file from the server using either your FTP client or via SSH with this command:
    rm db-backup-name.sql