Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 815
Subrata Avatar asked Jun 29 '12 18:06

Subrata


People also ask

How do I import a SQL zip file?

Import compressed file data into SQL Server. We want to load data from ZIP file into SQL Server table, therefore, add a Data Flow Task and connect it with the File Unzip Task. Rename Data Flow Task to Import Excel into SQL Server. Double click on the Import Excel into SQL Server.

How do I import a zip file into MySQL workbench?

To import a file, open Workbench and click on + next to the MySQL connections option. Fill in the fields with the connection information. Once connected to the database go to Data Import/Restore. Choose the option Import from Self-Contained File and select the file.


2 Answers

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.

like image 71
Kanuj Bhatnagar Avatar answered Sep 24 '22 17:09

Kanuj Bhatnagar


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

like image 45
Subrata Avatar answered Sep 21 '22 17:09

Subrata