Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Read .db file in Mosquitto

Tags:

mqtt

mosquitto

I'm using Mosquitto Project (http://mosquitto.org), this is my mosquitto.conf

persistence_file mosquitto.db

persistence_location C:/var/lib/mosquitto/

After running, I have got mosquitto.db, but I can't open it. I'm trying open with Microsoft Excel, sqlitebrowser_200_b1_win but it's not working. Please help me. Thanks in advance

like image 819
user958752 Avatar asked Dec 24 '12 07:12

user958752


People also ask

What is mosquitto DB?

Mosquitto is a lightweight open source message broker that Implements MQTT versions 3.1.0, 3.1.1 and version 5.0. It is written in C by Roger Light, and is available as a free download for Windows and Linux and is an Eclipse project.

How do I run mosquitto with config file?

conf and it is used by the mosquitto broker when started as a Linux daemon or Windows service. You will find the mosquitto. conf file in the /etc/mosquitto directory on Linux, and in the c:\mosquitto\ directory on Windows. Note: the Windows install lets you choose the directory.

How do I open a mosquitto MQTT file?

To start the broker manually open a command prompt and go to the mosquitto install directory and type mosquitto.


2 Answers

I just answered this same question on the mosquitto answers tracker:

https://answers.launchpad.net/mosquitto/+question/217523

The mosquitto.db file holds internal persistence information on client subscriptions and retained messages. It isn't intended for use outside of mosquitto. There is no guarantee that it is up to date information.

Having said that, if you are interested in looking at the file then the source file to look at is src/persist.c. There is also a program to print the file contents in a more readable manner - you should compile src/db_dump/db_dump.c.

mosquitto.db is an internal file and has nothing to do with sql.

like image 173
ralight Avatar answered Sep 30 '22 13:09

ralight


To read mosquitto.db file do these steps

git clone https://github.com/eclipse/mosquitto
cd mosquitto/apps/db_dump
make
sudo ./mosquitto_db_dump /var/lib/mosquitto/mosquitto.db

You'll then get output like

DB_CHUNK_SUB:
        Length: 54
        Client ID: <Your Client ID>
        Topic: <topic>
        QoS: 0
        Subscription ID: 0
        Options: 0x00

Or

DB_CHUNK_MSG_STORE:
        Length: 285
        Store ID: 28935676
        Source Port: 1883
        Source MID: 4027
        Topic: <topic>
        QoS: 1
        Retain: 0
        Payload Length: 190
        Expiry Time: 0
        Payload: <Payload>
like image 24
Hannes Avatar answered Sep 30 '22 14:09

Hannes