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
Unable to run mix ecto.create
without password, but mix ecto.migrate
works
#1207
Comments
The versions I used in my repro was:
|
Oh, nevermind. My database config (pg_hba.conf) was apparently wrong. For anyone else encountering this:
|
Also, Ecto master changed to use the same connections as ecto.migrate instead of using psql exactly because of those issues. So we hope this won't be a blocker to others soon. :D |
I am having the same problem please.
what do I do. new to elixir and phoenix, new to web programming. |
It's not the same problem - it's a different error. Is your database server running? |
Tried running that and it only produced another string of errors.
|
The book I'm reading says:
I did and saw the following inside the file:
don't know what to make of it or how to fix the error via it |
don't understand what they mean by
|
Okay, but that doesn't answer the question. You're trying to connect to Postgres - is Postgres installed and running on your machine? |
yes it is |
Problem solved. Took your advice and just downloaded another version of postgres and installed. then ran the mix ecto.create again:
|
Thanks once again @sevenseacat your question was the answer. |
❤️ 💚 💙 💛 💜 |
stack overflow: links this issue #1207 causing much confusion The solution to:
is:
working now:
reference: aside: reinstall could fix ** (Postgrex.Error) FATAL (invalid_password): password authentication failed for user "postgres" I think the key is config/dev.exs needs to match vaild postgres user I installed postgres on debian jessie with: each new install I need to fix postgres user password to match config config/dev.exs to work with
|
@jjahraus That's a great post describing solutions to some issues. However, your solution to have the The reason I created this issue from the start is that I am lazy and didn't want to have to enter database credentials when running in dev, since I have configured my local postgresql to allow my user to access most of it... or so I thought, at least. As it turned out I had failed to configure pg_hba.conf properly. Also, as @Gazler points out in the StackOverflow thread you linked to, in ecto 2.0, ecto won't use |
@Frost good points thanks for the info! Ill keep this in mind next time I setup a system, for now I am happy I can contiune working through Programming Phoenix book. |
@jjahraus Thanks for that! Now I can proceed. |
This worked for me:
Then in the terminal:
|
tried everything above |
@m13m That is probably because you are trying to use ident authentication and you are not running a local ident server on port 113. I am also running Fedora 25 (but the XFCE spin) and I don't seem to even have an ident server installed. I am guessing that this happens because Ecto nowadays tries to connect using TCP instead of a local socket (as explained earlier in this thread) combined with you not running an ident server locally. If you have netcat installed, you can run I think the solution to your problem is to either install and start an ident server or edit your Here's the PostgreSQL docs page on authentication methods if you want more reading: https://www.postgresql.org/docs/9.0/static/auth-methods.html |
Thanks @Frost To Fix the above Issue Replace
|
as of writing, these commands were needed to unbork postgres/ecto: sudo -u postgres psql -c "ALTER USER postgres PASSWORD 'postgres';" sudo /etc/init.d/postgresql restart see elixir-ecto/ecto#1207 jjahraus's 9 Nov 2016 comment
@roberthopman thank you :) that's the thing missing! On Mac OS to get up and running fast (with say Phoenix) simply run: brew install postgresql && brew services start postgresql && psql postgres then type:
then CTRL & D |
@jjahraus your answer deserves a medal |
@m13m thank you too! |
Getting the same issue. I'm currently on macOS Catalina with Postgres 12.2, elixir 1.10.2, phoenix 1.5.1 Here is my error message:
I have the 'postgres' user setup w/password set to 'postgres' aswell and this is present when I run
I tried changing 127.0.0.1/32 and ::1/128 to localhost, but got the same issue. I'm totally stumped. |
Usually, there is one line above that part of
Are you able to log in to your local postgresql instance with the I am guessing that will not work either, since your error message has So I'm guessing that if you want to use the If you want to just want any local account to access the database, try adding a line like this instead:
This is pretty much what I did in my own first reply to this issue as well, except that I specified that I only trust my own user. If you do that, you shouldn't need the |
tried both at the top of
Also, running SOLVED I checked what was running on port 5432 |
I checked in SQL Shell provided by PostgreSQL. The default username is -> postgres and the password was set at the time of PostgreSQL installation. |
weird that such issue still exist in 2021 Here is what worked for us
in case you have already a user created, you can alter the password like so:
Now go and run:
Have fun! |
I am running postgresql locally, and I allow my user to pretty much do everything with any local database, out of convenience.
The command line
psql
command automatically picks up my username, and tries to connect using that, and I would expect ecto to do the same if I don't provide one.However, this does not seem to be the case.
Running
mix ecto.create
results in the following error:However, if I create the database myself, using
createdb my_app_dev
, then runningmix ecto.migrate
works fine.How to reproduce this:
mix phoenix.new foo
)mix ecto.create
and watch it failcreatedb foo_dev
mix ecto.migrate
and it will reply withAlready up
This means I cannot run
mix test
, because that task recreates and migrates the database, which in turn means that I have to have working database credentials, at least in my test config, if I ever want to be able to runmix test
.I have tried digging around in the ecto source code, and I noticed that migrations and storage creation seem to be run in different parts of the code, but I couldn't manage to find where to change anything to allow this.
The text was updated successfully, but these errors were encountered: