Search code examples
ejabberd

how to access ejabberd`s mnesia directly?


ejabberd is running on ubuntu,version is 2.1.13,only one node,not distributed,and i want to query it`s mnesia database in ejabberdctl debug shell

i have tried use tv:start() in ejabberdctl debug shell,but it return

undefined function tv:start/0

i also tried

Cookie = 'MY_COOKIE'.
EjabberdNode = 'ejabberd@localhost'.
erlang:set_cookie(EjabberdNode, Cookie).
** exception error: distribution_not_started
   in function  auth:set_cookie/2 (auth.erl, line 119)
net_adm:ping(EjabberdNode).
rpc:call(EjabberdNode, mnesia, system_info, [tables]).

as you can see, i got an error seems for distribution.

and how to query tables in mnesia with a shell like mysql shell?


Solution

  • here my first node is ejabberd@localhost,for access mnesia of first node,we build another node test@localhost whitch generate a cluster with first node,and then you can access mnesia.

    command:

     erl -sname test -mnesia dir '"/tmp/"' -mnesia extra_db_nodes "['ejabberd@ubuntu']" -s mnesia
    

    attention: -sname test,must not same as the first node name,here is ejabberd then start mnesia by command

    mnesia:start().
    

    then you can check mnesia by command

     mnesia:info().
    

    good luck~