As per the docs you need to stop Mnesia in order to create the schema:
mnesia:create_schema(NodeList) initializes a new, empty schema. This is a mandatory requirement before Mnesia can be started. Mnesia is a truly distributed DBMS and the schema is a system table that is replicated on all nodes in a Mnesia system. This function fails if a schema is already present on any of the nodes in NodeList. The function requires Mnesia to be stopped on the all db_nodes contained in parameter NodeList. Applications call this function only once, as it is usually a one-time activity to initialize a new database.
When starting Mnesia you must wait for all the tables to be ready, like it is said in the docs:
Table initialization is asynchronous. The function call mnesia:start() returns the atom ok and then starts to initialize the different tables. Depending on the size of the database, this can take some time, and the application programmer must wait for the tables that the application needs before they can be used. This is achieved by using the function mnesia:wait_for_tables(TabList, Timeout), which suspends the caller until all tables specified in TabList are properly initiated.
A word of caution:
-
I lost all the records in my database when starting Mnesia after stopping it with
ctrl + c + c
and I was not able yet to find the cause for it, neither replicate it. While I am using Memento I don’t believe by looking to its code that is caused by the library, and instead I believe that I have hit some weird combination of factors that got Mnesia core confused on it’s start. You can check my post here. -
Also, Mnesia is not full ACID as claimed in the Erlang docs, but they say it his if you have enough replication(really ), see links:
-
The good and bad in Mnesia from my research can be found here.