如何将bzip输出传输到mysql以将数据从压缩文件直接恢复到数据库中

时间:2022-08-03 00:12:52

For making a dump of a database directly in bz2 format, I tried zipping the dump file directly using pipes, as follows:

为了以bz2格式直接转储数据库,我尝试使用管道直接压缩转储文件,如下所示:

mysqldump -u userName -p myDataBase | bzip2 -c > myDump.sql.bz2

I want to do a similar thing for restore. I can do this using 2 commands as follows: command 1:

我想做一个类似的恢复。我可以使用以下两个命令:命令1:

bzip2 -d myDump.sql.bz2

command 2:

命令2:

mysql -u userName -p myDataBase < myDump.sql

Wanted: Now I want to use the pipes to restore myDump.sql.bz2 to the database myDataBase.

Wanted:现在我想使用管道来恢复dummyp .sql。bz2到数据库myDataBase。

2 个解决方案

#1


24  

bzip2 -dc myDump.sql.bz2 | mysql -u userName -p myDatabase - the -c option to bzip2 makes it send output to stdout, which you're already using when you created the dump.

bzip2直流myDump.sql。bz2 | mysql -u用户名-p myDatabase - bzip2的-c选项将输出发送到stdout,您在创建转储时已经在使用它了。

#2


8  

try it:

试一试:

bzcat dump.sql.bz2 | mysql -u name -p db

#1


24  

bzip2 -dc myDump.sql.bz2 | mysql -u userName -p myDatabase - the -c option to bzip2 makes it send output to stdout, which you're already using when you created the dump.

bzip2直流myDump.sql。bz2 | mysql -u用户名-p myDatabase - bzip2的-c选项将输出发送到stdout,您在创建转储时已经在使用它了。

#2


8  

try it:

试一试:

bzcat dump.sql.bz2 | mysql -u name -p db