Background
I'm working on an mysql server with those hdd partitions:
...
/dev/vdd 99G 58G 39G 61% /var/lib/mysql
tmpfs 2,4G 0 2,4G 0% /tmp
...
I need to import a mysql dump into my database. Therefore I use the following syntax:
gunzip -c sql_dump.sql.gz | mysql -uDB_USER -p DB_NAME
In general this works but my sql_dump.sql.gz
file will be over 5GB when extracted.
The command above will fail with gzip: /home/.../sql_dump.sql.gz: No space left on device
. I think this is not related to the mysql
partiton which has enough space, but the /tmp
partition which does only have 2.4GB free.
For now I did go ahead an moved the file to the /var/lib/mysql
parition which has enough free space. gunzip my file there, start the mysql import and removed the compressed and uncompressed files afterward.
Question
I was asking myself if there is any way I can force gunzip
to temporary change the default temporary target location, which is /tmp/
by default. So that gunzip -c sql_dump.sql.gz | ...
does not store the extracted file under /tmp/
but under /var/lib/mysql
while extracting the file. Something like this:
export "GZIP_TMP_DIR=/var/lib/mysql/"
gunzip -c sql_dump.sql.gz | mysql -uDB_USER -p DB_NAME
Is this even possbile ? I searched a lot but could not find anything that would solve this specific need.
Set the desired temporary directory in environment variable TMPDIR
(see https://en.wikipedia.org/wiki/TMPDIR).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With