一、问题解决:
出现这个错误的原因是 解密的工具和加密文件的工具版本不一致 导致的,我们下载的 sqlcihper 源码是4.33版本的,而我们的数据库文件是由 sqlcihper3 加密得到的。sqlcipher4不提供对1-3数据库文件的解密。
1.1 sqlcipher版本查看:
$ sqlcipher --version
$ sqlcipher /home/apple/shared_nfs/EnMicroMsg.db
sqlite> PRAGMA cipher_version;
sqlite> PRAGMA key = 'yourkey';
1.2 问题的解决:
进行数据库文件迁移(cipher_migration),这个操作只需要进行一次,将数据库文件变成适合四版本的db文件。
sqlite> PRAGMA key = 'yourkey';
sqlite> PRAGMA cipher_migrate;
sqlite> SELECT count(1) FROM sqlite_master;
sqlite> .q
1.3 创建明文数据库:
在以后进行数据库操作前,首先设置密码,或者第一次进入就设置好。
$ sqlcipher
sqlite> .open/home/apple/shared_nfs/EnMicroMsg.db
sqlite> PRAGMA key = 'yourkey';
sqlite> .output 'MicroMsg.sql'
sqlite> .dump
sqlite> .open DeMicroMsg.db
sqlite> .read 'MicroMsg.sql'
sqlite> .databases
sqlite> SELECT count(1) FROM sqlite_master;
sqlite> .q
Original: https://blog.csdn.net/weixin_39517298/article/details/119006820
Author: 没有梦想的咸鱼~
Title: sqlcipher – Error: file is not a database
原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/816405/
转载文章受原作者版权保护。转载请注明原作者出处!