Wednesday 14 March 2018

Pipe gunzip and mysql to gunzip a dump and import it


I have a .gz sql dump file (example: foo.sql.gz) that i want import in my database with the classic mysql command.


gunzip -c foo.sql.gz > foo.sql

mysql -uroot -ppassword foo < foo.sql

foo is the database.


How can i pipe these two commands in a single one?


Tried


gunzip -c foo.sql.gz | mysql -uroot -ppassword foo

but doesn't seem to work; i get gzip: stdout: Broken pipe



Answer



zcat foo.sql.gz | mysql -uroot -ppassword foo

This will also leave foo.sql.gz as it is.


No comments:

Post a Comment

Where does Skype save my contact&#39;s avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...