> alias :mnesia, as: Mnesia
> Mnesia.create_schema([node()])
> fields = [:id, :to, :from, :body, :format, :metadata]
> Mnesia.create_table(:mail, [attributes: fields, disc_copies: [node()]] )
{:aborted, {:bad_type, :mail, :disc_copies, :nonode@nohost}}
如果我这样做
iex(5)> Mnesia.create_table(:mail, [attributes: fields] )
{:atomic, :ok}
一切都很好,但这只是在RAM中创建
如何使:mnesia
存储在磁盘上。
由于
答案 0 :(得分:1)
首先尝试命名您的节点:
> iex --name foo
然后你需要确保你开始Mnesia。这对我有用:
alias :mnesia, as: Mnesia
Mnesia.start()
Mnesia.create_schema([node()])
fields = [:id, :to, :from, :body, :format, :metadata]
Mnesia.create_table(:mail, [attributes: fields, disc_copies: [node()]] )
答案 1 :(得分:1)
Mnesia未正确启动。
iex(1)> :mnesia.create_schema([node()])
:ok
iex(2)> fields = [:id, :to, :from, :body, :format, :metadata]
[:id, :to, :from, :body, :format, :metadata]
iex(3)> :mnesia.start
:ok
iex(4)> :mnesia.create_table(:mail, [attributes: fields, disc_copies: [node()]] )
{:atomic, :ok}