本文用来记录自己遇到的问题,以及解决问题的方法。
刚上线的Android项目出现了database disk image is malformed(11) 第一次碰到这个错误有点懵逼,百度查了一下,原来是sqlite文件损坏了,有很多原因,不知道用户怎么用的就坏了。
官方说明: http://www.sqlite.org/lockingv3.html#how_to_corrupt
英文不太好 就没看下去了
我用的ubuntu系统 windows自己百度吧!实在搞不定可以找我,我可以给你解决,但不一定解决的了呦。
废话不说了 直接说自己的在网上找的方法吧,亲测可以用。
sqlite3安装
sudo apt-get install sqlite3
检查版本
sqlite3 -version
sqlite 文件修复
sqlite my.sqlite3
sqlite> PRAGMA integrity_check;
提示
*** in database main ***
Page 1446: btreeInitPage() returns error code 11
Page 1444: btreeInitPage() returns error code 11
Page 1443: btreeInitPage() returns error code 11
Page 1442: btreeInitPage() returns error code 11
首先导出数据
sqlite3 test.db
sqlite>.output tmp.sql
sqlite>.dump
sqlite>.quit
再导入到另一个新库中
sqlite3 new.db
sqlite>.read tmp.sql
sqlite>.quit
这就完成了整个修复过程,new.db 就可以用来了