Linux: On-the-fly import of zipped SQL files
by admin on Nov.19, 2016, under Linux (Ubuntu)
As you might already know, it’s possible to unpack files with the extensions tar.gz, tar.bz2, tgz and so on and directly import them into your MySQL database without having to store the extracted file onto your hard drive whatsoever. I recently tried to figure out how to do the same for regular zip files since not everyone in our company can be considered a macOS or *nix user.
Even though the regular zip/unzip utility that ships with many operating systems by default is not really suitable for piping its output, there’s another great tool called funzip that’s pre-installed on most systems and can do the same:
funzip dump.sql.zip | mysql -u root -p dbname
Even better, the tool doesn’t only support .zip files but also the .gz archive format.