[英]file is encrypted or is not a database - sqlite
I have some trouble to open a sqlite file 我在打开sqlite文件时遇到了一些麻烦
In the command line I get this: 在命令行中,我得到以下信息:
#sqlite3 sms.db
SQLite version 3.6.20
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> select * from message;
Error: file is encrypted or is not a database
The error is not when I connect, it's when I run a query 错误不是当我连接时,而是当我运行查询时
Checking the file gets me this 检查文件让我这个
# file sms.db
sms.db: SQLite 3.x database
So it should not be a version problem - like opening a sqlite2 file with sqlite3 因此,这应该不是版本问题-就像使用sqlite3打开sqlite2文件一样
In php I have this: 在PHP中我有这个:
try
{
/*** connect to SQLite database ***/
$db = new PDO("sqlite:path/sms.db");
echo "Handle has been created ...... <br><br>";
}
catch(PDOException $e)
{
echo $e->getMessage();
echo "<br><br>Database -- NOT -- loaded successfully .. ";
die( "<br><br>Query Closed !!! $error");
}
$result = $db->query('SELECT * from message') or var_dump($db->errorInfo());
Gets me this (not at connect but when the query is executed) 得到我这个(不是在连接时,而是在执行查询时)
array(3) { [0]=> string(5) "HY000" [1]=> int(26) [2]=> string(38) "file is encrypted or is not a database" }
I use a Sql manager extension for firefox and there I can open the file without any problems(and run any query without any encryption or password). 我为Firefox使用Sql管理器扩展,在那里我可以打开文件而没有任何问题(并且可以在没有任何加密或密码的情况下运行任何查询)。 This is really strange for me.
这对我来说真的很奇怪。 I have searched about this for the last hours but I didn't find any solution.
我已经搜索了最近几个小时,但是没有找到任何解决方案。 Any help would be appreciated.
任何帮助,将不胜感激。
I have just tested on windows and I can open the database. 我刚刚在Windows上进行了测试,可以打开数据库。 I think the problem is related to the sqlite drivers.
我认为问题与sqlite驱动程序有关。
On windows I have SQLite Library 3.7.7.1 On my centos server I have SQLite Library 3.6.20 在Windows上,我有SQLite库3.7.7.1在我的centos服务器上,我有SQLite库3.6.20
Now the question is how do I update the php sqlite extension. 现在的问题是如何更新php sqlite扩展。 I can not update the entire php (it may cause errors )
我无法更新整个php(可能会导致错误)
Commands like yum install php-pdo, yum install php5-sqlite3, do not work 像yum install php-pdo,yum install php5-sqlite3这样的命令不起作用
Sometimes I get this error when moving php-scripts from one hosting to another. 有时,将php-scripts从一台主机移到另一台时会出现此错误。 Most often it is bug in the mode sqlite WAL:
最常见的是sqlite WAL模式下的错误:
PRAGMA journal_mode = WAL;
To solve this problem you need to disable this option in the database. 要解决此问题,您需要在数据库中禁用此选项。 The easiest way to do this by replacing the 2 bytes in the file database \\x02\\x02 to \\x01\\x01 to the address \\x12 (dec 18) In bash, you can use commands:
通过将文件数据库\\ x02 \\ x02中的2个字节替换为\\ x01 \\ x01到地址\\ x12(12月18日)来执行此操作的最简单方法:在bash中,可以使用以下命令:
do printf '\x01\x01' | dd of=basename.db bs=1 seek=18 count=2 conv=notrunc
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.