How to import sql.gz file into database?

If you want to import sql.gz file into your database for your linux or mac o/s follow the steps below:

Importing sql.gz file using Linux/Ubuntu

# syntax using zcat command
zcat /path/to/file.sql.gz | mysql -u <mysql-user> -p <mysql-database>

# syntax using gunzip command
gunzip < /path/to/file.sql.gz | mysql -u <mysql-user> -p <mysql-database>

# syntax using gunzip command using -c, --stdout, --to-stdout option
gunzip -c /path/to/file.sql.gz | mysql -u <mysql-user> -p <mysql-database>

Importing sql.gz file using Mac OS

# syntax using zcat command
zcat < /path/to/file.sql.gz | mysql -u <mysql-user> -p <mysql-database>

# syntax using gzip command
cat /path/to/file.sql.gz | gzip -d | mysql -u <mysql-user> -p <mysql-database>