Skip to content

Instantly share code, notes, and snippets.

@keopx
Created July 16, 2015 18:36
Show Gist options
  • Star 14 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save keopx/c7ecd3b70d9672564f5a to your computer and use it in GitHub Desktop.
Save keopx/c7ecd3b70d9672564f5a to your computer and use it in GitHub Desktop.
Import gzipped sql using Drush
gunzip -c database.sql.gz | drush sqlc
@alvar0hurtad0
Copy link

drush sqlq --file=db.sql.gz

@alesrebec
Copy link

drush sqlq --file=db.sql.gz works, but make sure you drop the database first, else it might result with an error on import.
So the full command would be:

drush sql-drop && drush sqlq --file=db.sql.gz

You are still prompted for confirmation before it starts deleting tables.

@siliconmeadow
Copy link

drush sqlq --file=db.sql.gz works, but make sure you drop the database first, else it might result with an error on import.
So the full command would be:

drush sql-drop && drush sqlq --file=db.sql.gz

You are still prompted for confirmation before it starts deleting tables.

That doesn't seem to deal with the zipped file though. It didn't for me, anyway.

@alesrebec
Copy link

drush sqlq --file=db.sql.gz works, but make sure you drop the database first, else it might result with an error on import.
So the full command would be:
drush sql-drop && drush sqlq --file=db.sql.gz
You are still prompted for confirmation before it starts deleting tables.

That doesn't seem to deal with the zipped file though. It didn't for me, anyway.

That's because only gzip seems to be supported by drush sql-query (sqlq) command -> https://drushcommands.com/drush-8x/sql/sql-query/ (under --file option)

@jfcartier
Copy link

jfcartier commented Aug 7, 2021

zcat seems to be the right solution.
I used to use this method :
gunzip < /path/to/file.sql.gz | drush sql-cli --database=default

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment