压缩后sqlite3文件损坏

问题描述 投票:0回答:2

在我完成了我的db文件后,我尝试将其设为tar文件但在此之前我看到db文件的大小为3 MB。将其压缩到tar文件后,原始文件变为10 KB,压缩文件也变为10 KB。

这是我用来压缩文件的命令:

tar cf users.db /root/Desktop/users.tar  

我不知道发生了什么但是在文件的属性转向“STL 3D模型(二进制)(model / x.stl-binary)”它应该是“SQLite3数据库(application / x-sqlite3)”

我试图在sqlite3中使用.dump但没有修复它显示以下错误:

/**** ERROR: (26) file is not a database *****/
python sqlite
2个回答
1
投票

您对tar命令的参数不正确。语法是:

tar cf <archive to create> <files to add to the archive>

因为你把users.db放在<archive to create>位置,你已经用一个空的users.db档案取代了你的tar文件。除非您拥有数据库的备份,否则它已经消失了。


1
投票

在您写的评论中,您执行了此命令:

tar cf users.db /root/Desktop/users.tar

当您对tar使用f选项时,下一个参数指定要创建的文件。您所做的是归档现有文件(/root/Desktop/users.tar),并覆盖users.db。

在运行该命令后,users.db中的内容已被销毁。

© www.soinside.com 2019 - 2024. All rights reserved.