Make sure the directory where Mnesia is supposed to store files exists and the user that runs ejabberd has write access to it.
Since the name of this directory depends on the node name, make sure the node name is what you expect it to be. You can see the node name by starting erl with only the -name or -sname parameter, and looking at the prompt.
If the problem is that you modified your machine hostname, you have three solutions:
If the old Mnesia database doesn't contain important information, you can remove it and ejabberd will generate it again.
Another alternative is to modify the ejabberd start script, and set as erlang node name your old erlang node name. The node name is passed to Erlang with the options -sname or -name. Since ejabberd 2.0.0, the node name can be modified in the file /etc/ejabberd/ejabberdctl.cfg . In Debian and Ubuntu packages, it can be modified in the file /etc/default/ejabberd . With this change ejabberd will start correctly using the old database. But in order to use ejabberdctl, you may need to add the old machine hostname to /etc/hosts.
Directory
Directory (/var/lib/ejabberd) exists, user (ejabberd) have all rights. But error happens again.
This error message is shown
This error message is shown also in case when mnesia database is configured for using on another erlang node. Typical case is changing hostname.