During development environment setup we quite often have a database dump created with mysqldump and in gzip format, and we need to import it from the Linux command line.
In this tutorial, we assume the compressed dump file is
dump.sql.gz and it is located in the current working directory. In command line, type:
$ gunzip < dump.sql.gz | mysql -u username -p database
We first input the dump.sql.gz to the
gunzip which decompresses the dump and then we pipe it to thee
mysql client with a username and password, which is prompted. The
database is the (empty) database that we want to import the data to.
Note! If the dump.sql.gz contains CREATE DATABASE command, we can omit the database argument completely, like this:
$ gunzip < dump.sql.gz | mysql -u username -p
If the file is plain dump.sql. To import database from SQL file, check this article: MySQL Import Database from SQL File in Linux