Subrata
Subrata

Reputation: 2284

Importing zipped files in Mysql using command line

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

Upvotes: 43

Views: 89982

Answers (4)

Kanuj Bhatnagar
Kanuj Bhatnagar

Reputation: 1411

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.

Upvotes: 86

Subrata
Subrata

Reputation: 2284

I got the answer from my other question. This is the command to import zipped file when you are using 7zip

7z x -so backup.7z | mysql -u root test

x is the extraction command

-so option makes 7-zip write to stdout

Upvotes: 21

davev
davev

Reputation: 189

zcat backup.sql.gz | mysql -u[username] -p[pswd] [db]

Upvotes: 18

ESG
ESG

Reputation: 9435

You want might to try xz −−decompress −−stdout to decompress.

Full command would be xz −−decompress −−stdout backup.sql.gz | mysql -u root test

Upvotes: 0

Related Questions