-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
~/.my.cnf values should not override phoenix config! #193
Comments
Provide more info, please. Do you run db via docker? What about |
DB running in Docker for Mac. Elixir stuff on the host directly. docker-compose.yml:
config.exs:
dev.exs:
In my
the |
Are you sure that with setting default password in |
Why would I not be able to start the MySQL server if I only have |
I tried to run the same setup but stuck here: https://github.com/docker-library/mariadb/blob/master/10.2/docker-entrypoint.sh#L100. This is the reason why I ask. |
Oh, you're trying to reproduce the issue? You need nothing else but Docker and Docker Compose installed, then use the docker-compose.yml, maybe modify the port in there if you don't like the 3309, and execute OK, and just to clarify: I'm not using this file for configuring the server at all, and it would not work for that. Yes, if I install a MySQL server on a host (or in a Docker file) and in that environment I put a I'm not sure if this explanation was necessary, I just wanted to make sure the issue is absolutely clear. So there's really almost nothing to do to reproduce it. Docker Compose file as above, then create new standard phoenix project with mysql database option and then have a .my.cnf in your home folder where you set a password value in the |
Now I see. Check this https://github.com/elixir-ecto/ecto/blob/v2.1/lib/ecto/adapters/mysql.ex#L139. Ecto 2.1 uses |
Ok, that's unexpected. I'm wondering why they do it that way. It would seem logical to me to just use mariaex and consistently employ that to talk to MySQL, no matter when or where. MySQL cli tools should also not be required... Though I see that they provide To me it looks like an an open task that noone has taken care of yet -- move away from MySQL commandline tools and just use a library (i.e. mariaex) instead. Your thoughts? |
And about the actual password issue here: Why do they have this weird password handling there? Why don't they pass the password as they pass all other options as well? Why pass it as an env var? So that MySQL won't complain about passing password on the command line? (https://github.com/elixir-ecto/ecto/blob/v2.1/lib/ecto/adapters/mysql.ex#L301) |
Already fixed and will be available in Ecto 2.2, see elixir-ecto/ecto#1939 |
Alright, you guys are way ahead of me :D |
So close this issue because it is not related to |
Hi there,
first off, thanks for building this. Here's an issue I've found when creating and trying to run my first phoenix/elixir/maria app:
Created standard app with
mix phoenix.new --database mysql app
, didn't change anything, latest versions of Elixir, Erlang, Phoenix (just installed). Fetched deps and compiled.Created a mysql server with empty root password. Tried to run
mix ecto.create
, but got error from the mysql server that I'm using a password to connect to the instance, which was clearly (and by default) configured to be empty.** (Mix) The database for App.Repo couldn't be created: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
After consulting with folks in #elixir slack we couldn't find any solution. In the end, after more investigation, it turned out that something (can't tell whether mariaex or phoenix_ecto or ecto, since I'm a newbie) was reading my
~/.my.cnf
which had a default password configured and using that to override my locally-configured dev.exs values!This is super unexpected and, I believe, the wrong thing to do. The ~/.my.cnf is a global defaults file that should be used for values which are otherwise not configured, and should never override any options more specifically configured within a project.
Having said that I assume that this is simply a bug that occurs because a specifically configured empty password is assumed to be a non-specified option and is then overwritten by the value from the global
.my.cnf
.If desired I can, with a little guidance, work on a PR for solving this.
Thanks,
Denis
The text was updated successfully, but these errors were encountered: