Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check Mnesia database of ejabberd

I want to access Mnesia database of ejabberd server, But i don't know how to read,write and update the data, Is there a way by which i can do this. Can i change Database to MySQL rather than Mnesia. I have tried this

{odbc_server, {mysql, "localhost", "xmpp_db", "root", "**********"}}. 

Here "xmpp_db" is the name of my database which is created for ejabberd, But i does not see any change in xmpp_db. Should i create any tables in "xmpp_db", But problem is what are the names of my tables and fields. I also have used

ejabberdctl dump /tmp/ejabberd.db.txt 

command, But this is just for read the data(the data is in very roughly format and hard to understand). Is there any way by which i can perform read, write and update operations on Mnesia database.

your help will be appreciated.

like image 539
Hemant Sharma Avatar asked Apr 08 '15 13:04

Hemant Sharma


1 Answers

Is there any way by which i can perform read, write and update operations on Mnesia database?

General Info:

Using ejabberdctl you can get a list of Mnesia general information, tables, records count, directory of its file and etc.

$ ejabberdctl mnesia [info]

Data Manipulation:

One way for reading Mnesia records is by attach to ejabberd console and call mnesia:dirty_read/2 function with desired arguments.

$ ejabberdctl debug
1> mnesia:dirty_read(passwd, {<<"username">>, <<"host">>}).
[{passwd,{<<"username">>,<<"host">>}, <<"password">>}]

Also for updating (or writing) Mnesia records you can call mnesia:dirty_write/2 function the same way.

$ ejabberdctl debug
1> mnesia:dirty_write({passwd, {<<"user">>, <<"host">>, <<"new-pass">>}).
ok

For learning other Mnesia's API check its official manual.

like image 186
Hamidreza Soleimani Avatar answered Nov 16 '22 23:11

Hamidreza Soleimani