0
votes

Background: Set up new a new phoenix project with mysql (mix phenix.new learning_ecto --database mysql).

Running mix ecto.create worked fine. But running mix ecto.migrate resulted in:

21:53:09.973 [error] GenServer #PID<0.318.0> terminating ** (stop) %Mariaex.Error{mariadb: nil, message: "tcp connect: econnrefused"} Last message: nil State: [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]

A first clue: https://github.com/elixir-ecto/ecto/issues/1310 """ @amencarini that's because creating uses mysql from the command line while migrate uses the tcp socket. Can you please check your repository options in your config files? Does it have the proper host and port? Does ping localhost work on your terminal? """

and interestingly enough, port: ... was not automatically added to the config. So I added port: 3306. .. but it still didn't work.

1

1 Answers

1
votes

The issue was that network access to mysql was disabled in mamp.

Adding a port to config & activating network access in mamp solved the issue!

enter image description here

config/dev.ex
looks like this:

# 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