↑ ↓ select, Enter open, Esc close

Import a gzipped SQL dump into a database

Adjust the values, the command updates live
user@server
gunzip -c /var/www/vhosts/example.com/wp_example.sql.gz | mysql -u dbuser -p wp_example

Decompresses the backup without creating an intermediate file and passes the SQL statements to the MySQL client. Dumps from mysqldump contain DROP TABLE by default, so existing tables with the same name are replaced. Import uncompressed files with mysql -u dbuser -p wp_example < file.sql.

Note: Back up the current state first. The target database must exist unless the dump contains CREATE DATABASE.

Also searched as

  • import mysql dump
  • restore database backup
  • import sql.gz file

Related one-liners

All in MySQL and MariaDB

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.