使用mysql运行与eoenix运行混合ecto.migrate时的econnrefused

时间:2016-08-13 20:05:11

标签: mysql phoenix-framework ecto

背景: 用mysql设置一个新的凤凰项目(mix phenix.new learning_ecto --database mysql)。

运行mix ecto.create工作正常。 但运行混合ecto.migrate导致:

21:53:09.973 [错误] GenServer#PID< 0.318.0>终止 **(停止)%Mariaex.Error {mariadb:nil,message:“tcp connect:econnrefused”} 最后的消息:没有 状态:[sock_mod:Mariaex.Connection.Tcp,timeout:5000,otp_app :: learningEcto,repo:LearningEcto.Repo,adapter:Ecto.Adapters.MySQL,username:“xxxxxx”,password:“xxxxxx”,database:“learningecto_dev “,hostname:”localhost“,port:3306]

第一条线索: https://github.com/elixir-ecto/ecto/issues/1310 “”” @amencarini那是因为在迁移时使用命令行创建使用mysql使用tcp套接字。你能检查配置文件中的存储库选项吗?它有适当的主机和端口吗? ping localhost是否适用于您的终端? “”“

有趣的是,port:...没有自动添加到配置中。所以我添加了端口:3306. ..但它仍然无效。

1 个答案:

答案 0 :(得分:0)

问题是在mamp中禁用了对mysql的网络访问。

添加端口以配置&在mamp中激活网络访问解决了这个问题!

enter image description here

配置/ dev.ex
看起来像这样:

# Configure your database
config :learningEcto, LearningEcto.Repo,
  adapter: Ecto.Adapters.MySQL,
  username: "YourUsernameToMysqlHere",
  password: "YourPasswordToMysqlHere",
  database: "learningecto_dev",
  hostname: "localhost",
  port: 3306,
  pool_size: 10
相关问题