Install Sqlite And Query Firefox Log Files Using SQL

Firefox saves a lot of log information in RDBMS files that can be queried in sqlite, using standard SQL commands.




To query the files, you have to have the right version of sqlite. Turns out that an old version was installed with my Redhat Linux 6.4 installation and I had to upgrade it in order to see the data. Here is how you can install the software and query the logs.


When I ran sample sqlite queries I found on the web, I got lots of errors:

sqlite3 ./cookies.sqlite 'select count() from moz_cookies'
Error: file is encrypted or is not a database

attach “cookies.sqlite” as db1;
Error: file is encrypted or is not a database

sqlite3 cert8.db
SQLite version 3.6.20
Enter “.help” for instructions
Enter SQL statements terminated with a “;”

Error: file is encrypted or is not a database

Error: file is encrypted or is not a database

.open cookies.sqlite
Error: unknown command or invalid arguments: “open”. Enter “.help” for help

In this version, there was not even the command, .open!


which sqlite3

/usr/bin/sqlite3 --version

rpm -qa | grep -i "sqlite" | sort



sqlite> .version
SQLite 3.8.6 2014-08-15 11:46:33 9491ba7d738528f168657adb43a198238abde19e



The problems were solved by installing the latest version of sqlite.

Download the latest sqlite from:

mkdir /sqlite
- set the ownership and permissions

cd /sqlite
- copy the .gz file over to this directory.

gunzip sqlite-autoconf-3080600.tar.gz

tar xvf sqlite-autoconf-3080600.tar

cd sqlite-autoconf-3080600




as root:
make install


Turns out, that installing this latest version of sqlite, does not upgrade the package at all. It just unzips the software into a directory. The packages were the same as before.

So, the same software, between versions, was installed in two completely different ways! Thus the inspiration for my last post.


To see the Firefox log files:

cd /home/oracle/.mozilla/firefox/uxmtgwbm.default
ls -1 *.sqlite





You can then use sqlite like this:

cd /home/oracle/.mozilla/firefox/uxmtgwbm.default


sqlite> .open cookies.sqlite

sqlite> .open cookies.sqlite

sqlite> .databases
seq name file
— ————— ———————————————————-
0 main /sqlite/sqlite-autoconf-3080600/cookies.sqlite

sqlite> .tables

sqlite> select * from moz_cookies order by 2;



Nothing like using SQL for queries! Cool!



You could uninstall the old sqlite, and make a link for the new version. However, this older version of sqlite is from Oracle.

rpm -qa –info sqlite

Name : sqlite Relocations: (not relocatable)
Version : 3.6.20 Vendor: Oracle America
Release : 1.el6 Build Date: Fri 30 Apr 2010 03:38:45 AM CDT
Install Date: Mon 03 Jun 2013 07:42:04 PM CDT Build Host:
Group : Applications/Databases Source RPM: sqlite-3.6.20-1.el6.src.rpm
Size : 641180 License: Public Domain
Signature : RSA/8, Mon 03 Jan 2011 02:19:31 PM CST, Key ID 72f97b74ec551f03
Summary : Library that implements an embeddable SQL database engine
Description :
SQLite is a C library that implements an SQL database engine. A large
subset of SQL92 is supported. A complete database is stored in a
single disk file. The API is designed for convenience and ease of use.
Applications that link against SQLite can enjoy the power and
flexibility of an SQL database without the administrative hassles of
supporting a separate database server. Version 2 and version 3 binaries
are named to permit each to be installed on a single host

And, it keeps track of files involving yum.



Uninstalling the old version, and making a link “should” work. But if you look at my posts on how much time I spent overcoming Oracle Applications errors and links, I can’t help thinking something might break.


which sqlite3

which sqlite
/usr/bin/which: no sqlite in (/usr/lib64/qt-3.3/bin:

It’s easier to just make a link to the new sqlite3 and call it sqlite

as root:

cd /usr/local/bin
ln -s /sqlite/sqlite-autoconf-3080600/sqlite3 sqlite

ls -lrt
total 172
-rwxr-xr-x. 1 oracle root 2415 Jun 14 2013 dbhome
-rwxr-xr-x. 1 oracle root 5036 Jun 14 2013 oraenv
-rwxr-xr-x. 1 oracle root 4143 Jun 14 2013 coraenv
-rwxr-xr-x. 1 root root 153531 Sep 9 10:11 sqlite3
lrwxrwxrwx. 1 root root 39 Sep 10 11:25 sqlite -> /sqlite/sqlite-autoconf-3080600/sqlite3

sqlite –version
3.8.6 2014-08-15 11:46:33 9491ba7d738528f168657adb43a198238abde19e



Happy Queries!


Useful Links:

Download sqlite:

Install sqlite:


Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: