Alexandre1972

Alexandre1972 OP

Hi!

I’m new here.

I was reading this page:

https://hexdocs.pm/phoenix/up_and_running.html

And then, when I tried to run it, I’ve got this message:

19:26:35.127 [error] GenServer pid<0.259.0> terminating
** (Postgrex.Error) FATAL 28P01 (invalid_password) password authentication failed for user “postgres”
(db_connection 2.3.0) lib/db_connection/connection.ex:99: DBConnection.Connection.connect/2
(connection 1.0.4) lib/connection.ex:622: Connection.enter_connect/5
(stdlib 3.13.2) proc_lib.erl:226: :proc_lib.init_p_do_apply/3
Last message: nil
State: Postgrex.Protocol
** (Mix) The database for Hello.Repo couldn’t be created: killed

===

Does anybody know how can I fix?

Thank you for any help.

Alexandre.

phoenix mix #ecto.create

First 10 of 12 Posts Switch mode

Loopers97

Loopers97

I’m assuming you’re on windows, Go into Program Files/PostgreSQL/12/data . Find and open the pg_hba.conf . Scroll to the bottom, and change the row with 127.0.0.1/32. Change the method from md5 to trust. Obviously, don’t do this on a production setup.

Alexandre1972

Alexandre1972 OP

Loopers97, hi!

Thank you so much for your answer to my problem!

My O. S. is Debian Unstable/Sid (a Linux distro).

I’ve searched for this file using this command:

psql -t -P format=unaligned -c ‘show hba_file’

I saw this tip in the following website:

https://askubuntu.com/questions/256534/how-do-i-find-the-path-to-pg-hba-conf-from-the-shell

And then, I found out where it is:

/etc/postgresql/13/main/pg_hba.conf

Well, I made the changes, but I’ve got the same error message:

===

debian@sid:~/hello/hello$ mix ecto.create

23:47:49.715 [error] GenServer pid<0.259.0> terminating
** (Postgrex.Error) FATAL 28P01 (invalid_password) password authentication failed for user “postgres”
(db_connection 2.3.0) lib/db_connection/connection.ex:99: DBConnection.Connection.connect/2
(connection 1.0.4) lib/connection.ex:622: Connection.enter_connect/5
(stdlib 3.13.2) proc_lib.erl:226: :proc_lib.init_p_do_apply/3
Last message: nil
State: Postgrex.Protocol
** (Mix) The database for Hello.Repo couldn’t be created: killed

===

Alexandre.

Loopers97

Loopers97

I’m assuming you restarted the service after making the config change.

The logs makes it appear like the db is the issue, not ecto if that helps.

Try following this links guide. See if you can log in as postgres and get psql in the terminal. That’ll take ecto out from being a suspect.

https://chartio.com/resources/tutorials/how-to-set-the-default-user-password-in-postgresql/

Alexandre1972

Alexandre1972 OP

Hi again Looper97!

today I made some progress!
I didn’t restarted the service, so, I googled to know how to do this. And then I followed the instructions on this page:
https://avroblog.com/en/blog/content/How-to-restart-PostgreSQL

And now, when I type the “mix ecto.create” command, the error message is different:

===

** (Mix) The database for Hello.Repo couldn’t be created: ERROR 22023 (invalid_parameter_value) encoding “UTF8” does not match locale “en_GB”

The chosen LC_CTYPE setting requires encoding “LATIN1”.

===

I will google again and try to find a solution, then I come back here and post what I found.

Thank you!

Alexandre1972

Alexandre1972 OP

Hi again Loopers97!

Unfortunately, I was not sucessful… I regenerated my locales, using this command:

cd /usr/sbin

./dpkg-reconfigure locales

./locale-gen

But the error messages still are displayed to me:

===

** (Mix) The database for Hello.Repo couldn’t be created: ERROR 22023 (invalid_parameter_value) encoding “UTF8” does not match locale “en_GB”

The chosen LC_CTYPE setting requires encoding “LATIN1”.

===

I still need help …
Have you ever seen this problem before?

Loopers97

Loopers97

Progress is good. You’re dangerously close to getting postgres beat. The locale would have been set on the installation of postgres. I’m not sure what postgres locale defaults to. I’d recommend going digging into etc/lang.

Type locale and dump the output. I’m wondering if they’re all en_US.UTF-8

Loopers97

Loopers97

Here are the official docs for locale

tl;dr
The values that are chosen by initdb are actually only written into the configuration file postgresql.conf to serve as defaults when the server is started. If you remove these assignments from postgresql.conf then the server will inherit the settings from its execution environment. (server)

Always have the option to Nuke and pick the locale, now that you have gained some more knowledge.

Alexandre1972

Alexandre1972 OP

Hi again!

I have a lot of news to you!
Let’s go:

1) This is the what I get when I run the command locale:

debian@sid:~$ locale
LANG=en_GB
LANGUAGE=
LC_CTYPE=“en_GB”
LC_NUMERIC=“en_GB”
LC_TIME=“en_GB”
LC_COLLATE=“en_GB”
LC_MONETARY=“en_GB”
LC_MESSAGES=“en_GB”
LC_PAPER=“en_GB”
LC_NAME=“en_GB”
LC_ADDRESS=“en_GB”
LC_TELEPHONE=“en_GB”
LC_MEASUREMENT=“en_GB”
LC_IDENTIFICATION=“en_GB”
LC_ALL=
debian@sid:~$

2) Then I typed these commands in aterm:

root@sid:/usr/sbin# pg_dropcluster --stop 13 main
root@sid:/usr/sbin# pg_createcluster --locale en_GB.UTF-8 --start 13 main
Creating new PostgreSQL cluster 13/main …
/usr/lib/postgresql/13/bin/initdb -D /var/lib/postgresql/13/main --auth-local peer --auth-host md5 --locale en_GB.UTF-8
The files belonging to this database system will be owned by user “postgres”.
This user must also own the server process.

The database cluster will be initialized with locale “en_GB.UTF-8”.
The default database encoding has accordingly been set to “UTF8”.
The default text search configuration will be set to “english”.

Data page checksums are disabled.

fixing permissions on existing directory /var/lib/postgresql/13/main … ok
creating subdirectories … ok
selecting dynamic shared memory implementation … posix
selecting default max_connections … 100
selecting default shared_buffers … 128MB
selecting default time zone … America/Sao_Paulo
creating configuration files … ok
running bootstrap script … ok
performing post-bootstrap initialization … ok
syncing data to disk … ok

Success. You can now start the database server using:

pg_ctlcluster 13 main start

Ver Cluster Port Status Owner Data directory Log file
13 main 5432 online postgres /var/lib/postgresql/13/main /var/log/postgresql/postgresql-13-main.log
root@sid:/usr/sbin# pg_ctlcluster 13 main start

3) Then, I tried the mix command again, and guess what? The first error message, I almost died:

debian@sid:~/hello/hello$ mix ecto.create

11:52:57.370 [error] GenServer pid<0.259.0> terminating
** (Postgrex.Error) FATAL 28P01 (invalid_password) password authentication failed for user “postgres”
(db_connection 2.3.0) lib/db_connection/connection.ex:99: DBConnection.Connection.connect/2
(connection 1.0.4) lib/connection.ex:622: Connection.enter_connect/5
(stdlib 3.13.2) proc_lib.erl:226: :proc_lib.init_p_do_apply/3
Last message: nil
State: Postgrex.Protocol
** (Mix) The database for Hello.Repo couldn’t be created: killed
debian@sid:~/hello/hello$

4) But then, I did what you’ve told, and changed the file called pg_hba.conf with the “trust” value;

5) Then I restarted the postgrsql using the command systemctl restart postgresql in Debian.

6) Then I came back to the “hello” directory and tried to type the “mix ecto.create” again… and then… Finally!!!

7) Everything is fine now!!!

I will try to paste a screenshot of my term in this post:

I couldn’t have done it without your help… Thank you so much for your patience…

Now I will be able to follow the other steps on the tutorial I was reading.

A BIG, BIG Thank you!

A bright and happy week for you and your family!!!

Alexandre.

Loopers97

Loopers97

That’s great news, happy coding.

Windsound

Windsound

Thanks a lot! I have found my PostgreSQL folder and changed which made it working!
My PostgreSQL was installed at a different derive which is surprising to me.

Where Next? Top

Trending in Questions Top

stjefim
Hello! Suppose you are building workflow (order / task / payment) processing system with the following requirements: Each workflow con...
New
jonnycharles
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
spammy
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
dli
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app? Looking for hints regarding: Addi...
New
bottlenecked
Hi all, I wanted to ask how the community is dealing with post-release steps. Today we have Ecto migrations, which make sure that the db...
New
roeland
Kia ora, We have been using elixir-google-api to connect to Google Drive. However, with the updates to Tesla due to CVEs this is now bro...
New
michallepicki
I am using Oban and occasionally, shortly after a deployment, a handful of jobs can fail because of dependency on other parts of the syst...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge &amp; Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
juhalehtonen
There has been a thread to discuss the Stack Overflow Developer Survey on this forum every year since 2018, so here’s yet another one for...
New

We're in Beta

About us Mission Statement