↑ ↓ select, Enter open, Esc close

Import a gzipped dump into the WordPress database

Adjust the values, the command updates live
user@server
gunzip -c /var/www/vhosts/example.com/db-backup.sql.gz | wp db import - --path=/var/www/vhosts/example.com/httpdocs

Decompresses the dump as a stream and imports it using the credentials from wp-config.php. If the dump contains DROP TABLE statements (the mysqldump default), existing tables are replaced. Import uncompressed files directly with wp db import file.sql.

Note: Back up the current state with wp db export first. If the table prefix in the dump does not match $table_prefix in wp-config.php, WordPress will not find the data.

Also searched as

  • restore wordpress database backup
  • import sql file into wordpress
  • wp db import gz file

Related one-liners

All in WP-CLI

Read first, then run.

The commands on myline.de act directly on servers, files and databases. A wrong path or placeholder can delete data irreversibly or make a server unreachable.

  • All commands are provided without warranty and are not tested on every system.
  • Understand what a command does before running it, and check every placeholder.
  • Make a backup first and, if possible, try it on a test system.
  • You run commands at your own risk. Liability for damages is excluded to the extent permitted by law.