WordPress Hjälp

Export and import a database with WP-CLI

WP-CLI is a command line tool that helps you perform different actions on your WordPress site. If you're comfortable with using SSH commands, you'll notice that WP-CLI has simplified commands created for WordPress sites. Here's how you can use the database export and import commands available to WP-CLI.

Required: You'll need the following to complete these steps:
Note: If you have a VPS or DED Server, you need to install WP-CLI before you can start using it. WP-CLI is not available on our Windows Hosting plans.

Export the database with WP-CLI

  1. Connect to your hosting account with SSH.
  2. Use the bash command ls to list files and folders, and cd and ../ to move through directories until you're in the directory with your WordPress files.
  3. Enter the following command:
    wp db export filename.sql
    • In the command above, you should replace filename.sql with the name you want to use for the backup file.

You'll see a success message once the export is complete. Larger databases will take longer to export.

Note: Linux Hosting and Web Hosting Plus users may experience the following error:
mysqldump: Error: 'Access denied; you need (at least one of) the PROCESS privilege(s) for this operation' when trying to dump tablespaces
In most cases, your database will have been exported successfully, despite seeing this error. But we recommend confirming the export by checking your database tables manually.

Import the database with WP-CLI

  1. Upload the SQL backup file to the folder with your WordPress files using FTP or File Manager.
  2. Connect to your hosting account with SSH.
  3. Use the bash command ls to list files and folders, and cd and ../ to move through directories until you're in the directory with your WordPress files.
  4. Enter the following command:
    wp db import filename.sql
    • In the command above, you should replace filename.sql with the actual name of your backup file.

You'll see a success message once the import is complete. Larger databases will take longer to import.

More info

  1. If you don't have WP-CLI available on your server, you can use standard SSH commands to export and import databases.
  2. You can also export and import your database in phpMyAdmin.
  3. Find and replace for WordPress with SSH