elixir phoenix mix ecto.create时容易出的错误

来源:互联网 发布:网络打印提示被挂起 编辑:程序博客网 时间:2024/03/29 21:17

执行ecto.create

mix ecto.create

出现

** (Mix) The database for HelloPhoenix.Repo couldn't be created: an exception was raised:    ** (DBConnection.ConnectionError) tcp connect: connection refused - :econnrefused        (db_connection) lib/db_connection/connection.ex:148: DBConnection.Connection.connect/2        (connection) lib/connection.ex:622: Connection.enter_connect/5        (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3

首先确定是否已经安装postgres(MAC)

    brew install postgres

是否启动

    brew services to start/stop postgresql

如果提示role “postgres” does not exist,即如下错误

** (Postgrex.Error) FATAL (invalid_authorization_specification): role "postgres" does not exist    (db_connection) lib/db_connection/connection.ex:148: DBConnection.Connection.connect/2    (connection) lib/connection.ex:622: Connection.enter_connect/5    (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3

创建默认用户(MAC)

    initdb /usr/local/var/postgres    /usr/local/Cellar/postgresql/<version>/bin/createuser -s postgres

其中postgres为版本号,此时再执行ecto.create一般已经ok。

0 0
原创粉丝点击