Importing zipped files in Mysql using command line

Subrata picture Subrata · Jun 29, 2012 · Viewed 59.8k times · Source

Importing zipped files in Mysql using CMD

What is the right syntax to import sql zipped files into mysql using cmd ?

I am doing the following

xz < backup.sql.gz | mysql -u root test

But always getting the following error enter image description here

Answer

Kanuj Bhatnagar picture Kanuj Bhatnagar · Nov 12, 2015

Try:

unzip -p dbdump.sql.zip | mysql -u root -p yourdbname

The dbdump.sql.zip should contain a single SQL file. The -p flag pipes the output into the mysql binary.