Skip to content
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

create database - mix ecto.create - error #1624

Closed
honza777 opened this issue Mar 31, 2016 · 7 comments
Closed

create database - mix ecto.create - error #1624

honza777 opened this issue Mar 31, 2016 · 7 comments

Comments

@honza777
Copy link

### Environment

  • Elixir version (elixir -v): 1.3.0-dev (aec2d29)
  • Phoenix version (mix deps): 1.1.4
  • NodeJS version (node -v): 0.10.42
  • NPM version (npm -v): 1.3.6
  • Operating system: Centos 6.7 32-bit

### Expected behavior

$ mix ecto.create
The database for HelloPhoenix.Repo has been created.

### Actual behavior

//when I tried to create database, I received this error:

[root@centos66a hello_phoenix]# mix ecto.create

** (Mix) The database for HelloPhoenix.Repo couldn't be created, reason given: psql: FATAL: Ident authentication

failed for user "postgres"

//There is troublesooting that can fix this by creating the "postgres" role with the permissions needed to log in and

create a database.

=# CREATE ROLE postgres LOGIN CREATEDB;
CREATE ROLE

//but when I entered , I received this error:

postgres-# CREATE ROLE postgres LOGIN CREATEDB;
ERROR: syntax error at or near "su"
LINE 1: su - postgres
^

//but I found that postgres role already exist:

postgres-# pg_roles;
rolname


postgres
(1 row)

// after config/dev.exs set watchers to empty:
watchers: []

error changed:
[root@centos66a config]# mix ecto.create
** (Mix) The task "ecto.create" could not be found

@chrismccord
Copy link
Member

Looks like you ran the task from the config/ dir, so go back to your project root and re-run the mix ecto.create task and report back. Watchers are unrelated to anything database wise. This sounds like a postgres configuration issue. What configuration do you have in your pg_hba.conf for authentication?

@honza777
Copy link
Author

[root@centos66a config]# cd /Users/me/work/elixir-stuff/hello_phoenix
[root@centos66a hello_phoenix]# mix ecto.create
Compiled lib/hello_phoenix.ex
Compiled web/channels/user_socket.ex
Compiled web/views/error_helpers.ex
Compiled web/gettext.ex
Compiled web/web.ex
Compiled lib/hello_phoenix/repo.ex
Compiled web/views/error_view.ex
Compiled web/router.ex
Compiled web/controllers/page_controller.ex
Compiled web/views/page_view.ex
Compiled web/views/layout_view.ex
Compiled lib/hello_phoenix/endpoint.ex
Generated hello_phoenix app
Consolidated Poison.Decoder
Consolidated Phoenix.HTML.FormData
Consolidated List.Chars
Consolidated Ecto.DataType
Consolidated DBConnection.Query
Consolidated Plug.Exception
Consolidated Ecto.Queryable
Consolidated Phoenix.Param
Consolidated Collectable
Consolidated Enumerable
Consolidated Phoenix.HTML.Safe
Consolidated String.Chars
Consolidated IEx.Info
Consolidated Poison.Encoder
Consolidated Inspect
** (Mix) The database for HelloPhoenix.Repo couldn't be created, reason given: psql: FATAL: Ident authentication failed for user "postgres"

/var/lib/pgsql/9.5/data/pg_hba.conf

TYPE DATABASE USER ADDRESS METHOD

"local" is for Unix domain socket connections only

local all all peer

IPv4 local connections:

host all all 127.0.0.1/32 ident

IPv6 local connections:

host all all ::1/128 ident

Allow replication connections from localhost, by a user with the

replication privilege.

#local replication postgres peer
#host replication postgres 127.0.0.1/32 ident
#host replication postgres ::1/128 ident

@chrismccord
Copy link
Member

Try this SO answer:

Edit the file /etc/postgresql/8.4/main/pg_hba.conf and replace ident or peer by either md5 or trust, depending on whether you want it to ask for a password on your own computer or not. Then reload the configuration file with:

/etc/init.d/postgresql reload

http://stackoverflow.com/a/7526119

If that doesn't work, please try the phoenix-talk mailing list where a well versed pg person may be able to help out. Thanks!

@honza777
Copy link
Author

I replaced ident by md5.

TYPE DATABASE USER ADDRESS METHOD

"local" is for Unix domain socket connections only

local all all peer

IPv4 local connections:

host all all 127.0.0.1/32 md5

IPv6 local connections:

host all all ::1/128 md5

Allow replication connections from localhost, by a user with the

replication privilege.

#local replication postgres peer
#host replication postgres 127.0.0.1/32 md5
#host replication postgres ::1/128 md5

but when I tried reload the configuration file I received message that Directory or File doesn't exist:

[root@centos66a hello_phoenix]# /etc/init.d/postgresql reload
bash: /etc/init.d/postgresql: Adresář nebo soubor neexistuje

Chris, where I can obtain the phoenix-talk mailing list ?
Thank you

@tmjoen
Copy link
Contributor

tmjoen commented Mar 31, 2016

@honza777
Copy link
Author

Thanks Mjoen

@arcseldon
Copy link

Answer here - https://stackoverflow.com/a/35497667/1882064

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants