【问题标题】:How can I connect to Postgres with mix command on Phoenix framework?如何在 Phoenix 框架上使用 mix 命令连接到 Postgres?
【发布时间】:2019-01-11 16:35:18
【问题描述】:

我正在尝试在 Phoenix 项目上运行 mix ecto.create 并出现错误:

00:30:34.332 [error] GenServer #PID<0.328.0> terminating 
    (RuntimeError) Connect raised a CaseClauseError error. The exception details are hidden, as they may contain sensitive data such as database credentials.
    (postgrex) lib/postgrex/utils.ex:40: Postgrex.Utils.parse_version/1
    (postgrex) lib/postgrex/protocol.ex:497: Postgrex.Protocol.bootstrap_send/4
    (postgrex) lib/postgrex/protocol.ex:353: Postgrex.Protocol.handshake/2
    (db_connection) lib/db_connection/connection.ex:135: DBConnection.Connection.connect/2
    (connection) lib/connection.ex:622: Connection.enter_connect/5
    (stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3                                                  
Last message: nil
State: Postgrex.Protocol
(Mix) The database for Discuss.Repo couldn't be created: an exception was raised:
(RuntimeError) Connect raised a CaseClauseError error. The exception details are hidden, as they may contain sensitive data such as database credentials.
        (postgrex) lib/postgrex/utils.ex:40: Postgrex.Utils.parse_version/1
        (postgrex) lib/postgrex/protocol.ex:497: Postgrex.Protocol.bootstrap_send/4
        (postgrex) lib/postgrex/protocol.ex:353: Postgrex.Protocol.handshake/2
        (db_connection) lib/db_connection/connection.ex:135: DBConnection.Connection.connect/2
        (connection) lib/connection.ex:622: Connection.enter_connect/5
        (stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3

我的配置/dev.exs

# Configure your database
config :discuss, Discuss.Repo,
  adapter: Ecto.Adapters.Postgres,
  username: "elixir",
  password: "Ohtai3ai",
  database: "discuss_dev",
  hostname: "127.0.0.1",
  pool_size: 10

我的 Elixir 版本是 1.6.6(使用 OTP 19 编译) Postgres 10

【问题讨论】:

    标签: postgresql elixir phoenix-framework


    【解决方案1】:

    已解决。只需更新新版本 phoenix_ecto 3.3.0 postgrex 0.13.5 ecto 2.2.10

    【讨论】:

      【解决方案2】:

      过时的postgrex 依赖可能是原因,尝试升级它。

      mix deps.update postgrex
      

      解决方案来自postgrex issue #370googling the exact error message 很容易找到。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-01-05
        • 2018-06-05
        • 2016-10-27
        • 2017-05-05
        • 2015-12-25
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多