MySQL拒绝Elixir 1.9连接

时间:2019-07-02 20:08:10

标签: mysql docker-compose elixir

我已从Elixir 1.8.2-> 1.9.0更新。 MySQL现在拒绝连接,并显示错误:Aborted connection 7 to db: 'some-api' user: 'some_user' host: '172.28.0.5' (Got an error reading communication packets)

此应用程序正在docker-compose中运行,并且在Elixir 1.8.2上可以正常工作。

使用docker-compose启动数据库,然后使用MYSQL_HOST=localhost iex -S mix phx.server运行Elixir应用程序时,该应用程序运行良好,这使我相信此问题与Docker的关系远大于Elixir

我尝试将配置的max_packet_allowed部分中的MySQL [mysql], [client], [mysqld]变量调升为无效。

docker-compose.json

{
  "version": "3",
  "services": {
    "some-api": {
      "build": {
        "args": [
          "MYSQL_HOST=some_mysql"
        ],
        "context": "./../some-api"
      },
      "container_name": "some-api",
      "depends_on": [
        "some_mysql",
      ],
      "networks": [
        "somenetwork"
      ],
      "ports": [
        "4000:4000"
      ],
      "volumes": [
        "./../some-api:/code/some-api",
        "/code/some-api/deps"
      ]
    },
    "some_mysql": {
      "container_name": "some_mysql",
      "environment": {
        "MYSQL_ROOT_PASSWORD": "password"
      },
      "image": "mysql:5.7",
      "networks": [
        "somenetwork"
      ],
      "ports": [
        "3306:3306"
      ],
      "volumes": [
        "./services/mysql/db:/var/lib/mysql",
        "./services/mysql/config:/etc/mysql/conf.d"
      ]
    },
  }
}

Elixir配置:

config :some_repo, SomeRepo.Repo,
  database: "some-api",
  username: "some_user",
  password: "some_pass",
  hostname: "some_mysql",
  port: 3306

2 个答案:

答案 0 :(得分:0)

iex最终成为问题。当我们将命令切换为elixir(其他都保持不变)时,它就起作用了。

仍然不确定根本原因。

答案 1 :(得分:0)

我不得不删除_build并重新编译。然后它起作用了。