{"id":25,"date":"2010-01-26T17:43:14","date_gmt":"2010-01-26T14:43:14","guid":{"rendered":"http:\/\/meekconsulting.com\/?p=25"},"modified":"2010-01-26T17:43:14","modified_gmt":"2010-01-26T14:43:14","slug":"loading-compressed-file-into-mysql-without-uncompressing","status":"publish","type":"post","link":"https:\/\/meekconsulting.com\/?p=25","title":{"rendered":"Loading compressed file into mysql without uncompressing"},"content":{"rendered":"<p>If you have a compressed file from a mysqldump backup of your mysql database, and you don\u2019t have space to uncompress it to load it on another machine.\u00a0 You can load it directly from the compress file using this command:<\/p>\n<blockquote><p>zcat backupdump.sql.gz | mysql -uusername -p databasename<\/p><\/blockquote>\n<p>This will uncompress the file on the fly without using the space to hold the uncompressed file.<\/p>\n<p><strong>NOTE:<\/strong> You can create a compressed on the fly backup of a table by doing this command:<\/p>\n<blockquote><p>mysqldump -uuser -ppass dbname tablename | gzip \u2013 > backupdump.sql.gz<\/p><\/blockquote>\n<p>Leave out the tablename to dump the entire database..<\/p>\n<p>I run this command in backup scripts for all my databases every night from cron.<\/p>\n<p>These backup scripts typically look like this to name the file using todays date:<\/p>\n<blockquote><p>#!\/bin\/bash<\/p>\n<p>cd \/backupdirectory<\/p>\n<p>DAY=`date \u2018+%m%d%y\u2019`<\/p>\n<p>OUTFILE=\u201ddataabasename.dmp.sql.$DAY.gz\u201d<\/p>\n<p>mysqldump -uuser -ppass dbname | gzip \u2013 > $OUTFILE<\/p>\n<p>scp $OUTFILE remoteserverforsafekeeping.com:\/backups<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>If you have a compressed file from a mysqldump backup of your mysql database, and you don\u2019t have space to uncompress it to load it on another machine.\u00a0 You can load it directly from the compress file using this command: &hellip; <a href=\"https:\/\/meekconsulting.com\/?p=25\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/meekconsulting.com\/index.php?rest_route=\/wp\/v2\/posts\/25"}],"collection":[{"href":"https:\/\/meekconsulting.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/meekconsulting.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/meekconsulting.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/meekconsulting.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=25"}],"version-history":[{"count":1,"href":"https:\/\/meekconsulting.com\/index.php?rest_route=\/wp\/v2\/posts\/25\/revisions"}],"predecessor-version":[{"id":26,"href":"https:\/\/meekconsulting.com\/index.php?rest_route=\/wp\/v2\/posts\/25\/revisions\/26"}],"wp:attachment":[{"href":"https:\/\/meekconsulting.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=25"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meekconsulting.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=25"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meekconsulting.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=25"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}