msvrtan's blog

Importing data from compressed files directly to MySQL

This is a neat trick for directly importing compressed MySQL dump files into MySQL


xz -dc /folder-of-my-choice/filename.xz | mysql -u username -pmy_password


It might not be of much use to everyone, but if you found yourself in situation where you first had to uncompress a few GB file and then import it this will really speed up the process.

Key option here is '-c' which enables decompressing to standard output and '|' allows us to send that data directly into MySQL importer. Though this example is using xz tool,  most uncompressing tools should have a similar option.