beta.blog

Archive for November, 2016

Linux: On-the-fly import of zipped SQL files

by 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.

Leave a Comment more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!