简体   繁体   中英

how to dump sql.gz file in to mysql

I have allocated almost all of my space on the production server to my table space

Now i have an compressed dump of around 20gb which is needed to be dumped into mysql

The problem is the server is not having much space to uncompress the file (which requires around 120 gb)

i have used the beolw command but i am a failure because it is first uncompressing the file and then redirecting the output to mysql

 gunzip dbdump.sql.gz | mysql -u root -proot123 -S /home/mysql55/tmp/mysql.sock 

Is there any way so that i can dump the compressed file without uncompressing it

any suggestions are really grateful

You should tell gunzip to write to standard out. What you are doing right now is not going to pipe any output at all.

gunzip -c dbdump.sql.gz | mysql (args...)

I know this is ridiculous, but it was gzipped twice, so

  1. Extract filename.sql.gz
  2. Rename extracted file from filename.sql to filename.gz
  3. Extract again

Hope it will work

We can achieve the same with the below command as well. Here i am using gzip

gzip -d < dbdump.sql.gz | mysql (args..)

Another way is as given below

gzip -c dbdump.sql.gz | mysql (args..)

您可以使用此导入。

zcat dbdump.sql.gz | mysql -u username -p dbname

您可以尝试动态解压缩文件,例如:

$ cat dbdump.sql.gz | gzip -cd | mysql

I would recommend getting gunzip. Here is one for windows: http://gnuwin32.sourceforge.net/packages/gzip.htm

Once you unzip, you can upload your .sql

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM