Linux 如何将 sql.gz 文件转储到 mysql
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15643737/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to dump sql.gz file in to mysql
提问by vidyadhar
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
现在我有一个大约 20gb 的压缩转储,需要将其转储到 mysql
The problem is the server is not having much space to uncompress the file (which requires around 120 gb)
问题是服务器没有太多空间来解压缩文件(大约需要 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
我已经使用了 beolw 命令,但我失败了,因为它首先解压缩文件,然后将输出重定向到 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
任何建议都非常感谢
回答by Andrew Mao
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
写标准输出。您现在所做的根本不会通过管道传输任何输出。
gunzip -c dbdump.sql.gz | mysql (args...)
回答by vidyadhar
We can achieve the same with the below command as well. Here i am using gzip
我们也可以使用以下命令实现相同的效果。我在这里使用 gzip
gzip -d < dbdump.sql.gz | mysql (args..)
Another way is as given below
另一种方法如下所示
gzip -c dbdump.sql.gz | mysql (args..)
回答by kenorb
You may try to uncompress the file on the fly, in example:
您可以尝试动态解压缩文件,例如:
$ cat dbdump.sql.gz | gzip -cd | mysql
回答by askoura
I know this is ridiculous, but it was gzipped twice, so
我知道这很荒谬,但它被压缩了两次,所以
- Extract
filename.sql.gz
- Rename extracted file from
filename.sql
tofilename.gz
- Extract again
- 提炼
filename.sql.gz
- 将提取的文件重命名
filename.sql
为filename.gz
- 再次提取
Hope it will work
希望它会起作用
回答by Robert Livingston
I would recommend getting gunzip. Here is one for windows: http://gnuwin32.sourceforge.net/packages/gzip.htm
我会推荐使用 gunzip。这是 Windows 的一个:http: //gnuwin32.sourceforge.net/packages/gzip.htm
Once you unzip, you can upload your .sql
解压后,您可以上传您的 .sql