使用命令行在 Mysql 中导入压缩文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11267309/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 14:00:40  来源:igfitidea点击:

Importing zipped files in Mysql using command line

mysqldatabasecmdwinzipxz

提问by Subrata

Importing zipped files in Mysql using CMD

使用CMD在Mysql中导入压缩文件

What is the right syntax to import sql zipped files into mysql using cmd ?

使用 cmd 将 sql 压缩文件导入 mysql 的正确语法是什么?

I am doing the following

我正在做以下事情

xz < backup.sql.gz | mysql -u root test

But always getting the following error enter image description here

但总是出现以下错误 在此处输入图片说明

采纳答案by Subrata

I got the answer from my other question. This is the command to import zipped file when you are using 7zip

我从我的另一个问题中得到了答案。这是使用 7zip 时导入压缩文件的命令

7z x -so backup.7z | mysql -u root test

7z x -so 备份.7z | mysql -u 根测试

x is the extraction command

x 是提取命令

-sooption makes 7-zip write to stdout

-so选项使 7-zip 写入标准输出

回答by Kanuj Bhatnagar

Try:

尝试:

unzip -p dbdump.sql.zip | mysql -u root -p yourdbname

The dbdump.sql.zip should contain a single SQL file. The -p flag pipes the output into the mysql binary.

dbdump.sql.zip 应包含单个 SQL 文件。-p 标志将输出通过管道传输到 mysql 二进制文件中。

回答by davev

zcat backup.sql.gz | mysql -u[username] -p[pswd] [db]

回答by ESG

You want might to try xz ??decompress ??stdoutto decompress.

你可能想尝试xz ??decompress ??stdout解压。

Full command would be xz ??decompress ??stdout backup.sql.gz | mysql -u root test

完整的命令是 xz ??decompress ??stdout backup.sql.gz | mysql -u root test