使用CMD在Mysql中导入压缩文件 [英] Importing zipped files in Mysql using CMD
问题描述
我正在尝试使用以下命令使用命令提示符将压缩的数据库文件导入 Mysql
I am trying to import zipped database files into Mysql using command prompt using the following command
7z < backup.sql.7z | mysql -u root test
root 用户没有有任何与之关联的密码.
test 是我的目标空白数据库.我使用 7zip 来解压.压缩后的数据库,即 backup.sql.7z 位于 D 盘.
The root user don't have any password associated with it.
test is my target blank database.
I use 7zip for unzipping purpose.
The zipped database i.e. backup.sql.7z is located in D drive.
但它给出了以下错误
所以,我使用了以下命令
So, instead I used the following command
7z < backup.7z | mysql -u root test
注意:这次我使用的是 backup.7z 而不是 backup.sql.7z
Note: This time I am using backup.7z instead of backup.sql.7z
但是我收到以下错误
显然我的 SQL 语法有问题.
Clearly there's something wrong with my SQL syntax.
那么正确的语法是什么?
What will be the correct syntax to use then ?
推荐答案
我也需要从压缩文件导入,偶然发现了您的问题.经过一番折腾,我发现这对我有用:
I needed to import from a compressed file as well, and stumbled upon your question. After a bit of messing around, I found that this worked for me:
7z x -so backup.7z | mysql -u root test
x 是提取命令
-so 使 7-zip 写入标准输出
x is the extraction command
-so makes 7-zip write to stdout
这篇关于使用CMD在Mysql中导入压缩文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!