# Error: file is not a database when using .open

**URL:** <https://discuss.zetetic.net/t/error-file-is-not-a-database-when-using-open/5066>\
**Category:** Issues\
**Created:** [August 2, 2021, 11:49pm UTC](https://discuss.zetetic.net/t/error-file-is-not-a-database-when-using-open/5066 "2021-08-02T23:49:21Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![anphetamina](https://avatars.discourse-cdn.com/v4/letter/a/b5a626/32.png) [@anphetamina](https://discuss.zetetic.net/u/anphetamina)\
**Post date:** [August 2, 2021, 11:49pm UTC](https://discuss.zetetic.net/t/error-file-is-not-a-database-when-using-open/5066/1 "2021-08-02T23:49:22Z")

</div>

My encrypted db can successfully be accessed by launching `sqpcipher mydb.db` and setting the key. However, when I first launch `sqlcipher`, doing `.open mydb.db` will cause to raise an `Error: file is not a database` after every statement.

The sqlcipher version is `4.4.2 (Community edition)` without any mismatch between the version used to create the database and the version used to access it.

What’s wrong here?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![developernotes](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.zetetic.net/developernotes/32/1309_2.png) [@developernotes](https://discuss.zetetic.net/u/developernotes)\
**Post date:** [August 3, 2021, 7:47pm UTC](https://discuss.zetetic.net/t/error-file-is-not-a-database-when-using-open/5066/2 "2021-08-03T19:47:06Z")

</div>

Hi @anphetamina

You need to supply the key after you use the `.open` command within the SQLCipher shell. For example on a SQLCipher-encrypted database:

```auto
$ ./sqlcipher
sqlite> .open foo.db
sqlite> PRAGMA key = 'foo';
sqlite> SELECT * FROM t1;

```

Are you doing this?

---

<div class="post-metadata">

**Author:** ![anphetamina](https://avatars.discourse-cdn.com/v4/letter/a/b5a626/32.png) [@anphetamina](https://discuss.zetetic.net/u/anphetamina)\
**Post date:** [August 3, 2021, 9:32pm UTC](https://discuss.zetetic.net/t/error-file-is-not-a-database-when-using-open/5066/3 "2021-08-03T21:32:47Z")

</div>

Exactly, I even tried setting the key prior the `.open`

---

<div class="post-metadata">

**Author:** ![developernotes](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.zetetic.net/developernotes/32/1309_2.png) [@developernotes](https://discuss.zetetic.net/u/developernotes)\
**Post date:** [August 3, 2021, 9:58pm UTC](https://discuss.zetetic.net/t/error-file-is-not-a-database-when-using-open/5066/4 "2021-08-03T21:58:50Z")

</div>

Hi @anphetamina

What is printed within your shell when you execute the following command:

```auto
PRAGMA cipher_version;

```

---

<div class="post-metadata">

**Author:** ![anphetamina](https://avatars.discourse-cdn.com/v4/letter/a/b5a626/32.png) [@anphetamina](https://discuss.zetetic.net/u/anphetamina)\
**Post date:** [August 5, 2021, 11:54am UTC](https://discuss.zetetic.net/t/error-file-is-not-a-database-when-using-open/5066/5 "2021-08-05T11:54:51Z")

</div>

> sqlite\> PRAGMA cipher\_version;  
> 4.4.2 community

---

<div class="post-metadata">

**Author:** ![sjlombardo](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.zetetic.net/sjlombardo/32/3_2.png) [@sjlombardo](https://discuss.zetetic.net/u/sjlombardo)\
**Post date:** [September 9, 2021, 11:32pm UTC](https://discuss.zetetic.net/t/error-file-is-not-a-database-when-using-open/5066/6 "2021-09-09T23:32:50Z")

</div>

@anphetamina This appears to work as expected for me with the latest release version

```auto
$ ./sqlcipher
SQLite version 3.34.1 2021-01-20 14:10:07 (SQLCipher 4.4.3 community)
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> .open test.db
sqlite> pragma key = 'test';
ok
sqlite> .schema
CREATE TABLE t1(a,b);
sqlite> select * from t1;
1|2

```
