What is the default password for User postgres

I used Ubuntu 18.04.2 LTS
Erlang/OTP 22 [erts-10.4] [source] [64-bit] [smp:2:2] [ds:2:2:10] [async-threads:1] [hipe]

Interactive Elixir (1.8.1) - press Ctrl+C to exit (type h() ENTER for help)
Phoenix v1.4.6

I have installed PostgreSQL 10.8, for work with elixir and phoenix framework,
before hand I make new password in postgresql

$ sudo -i -u postgres psql
postgres=# \password
Enter new password:12345
Enter it again: 12345
postgres=#\q

but when I ran my phoenix, I got problem like this:
$ mix ecto.create
The database for Lat7.Repo has already been create

$ mix test

04:28:07.850 [error] GenServer #PID<0.217.0> terminating
** (Postgrex.Error) FATAL 28P01 (invalid_password) password authentication failed for user “postgres”
(db_connection) lib/db_connection/connection.ex:84: DBConnection.Connection.connect/2
(connection) lib/connection.ex:622: Connection.enter_connect/5
(stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Last message: nil
** (Mix) The database for Lat7.Repo couldn’t be created: killed

By default there is no password and postgres delegates the login to the system. So if you connect to the DB as a local user postgres then you are signed in, otherwise the connection is rejected. And this is exactly what flag -u in sudo does.

1 Like

Its really not a good practise to be using the role postgres for your application needs. Its the “superuser” of Postgres.

$ createuser my_app
$ createdb my_app
$ psql -U my_app
psql (9.6.3)
Type "help" for help.

my_app=> \q

And then adjust the permissions on the role my_app to suit.

6 Likes

Yes… I have created new User and new Database, but when I ran
$ mix ecto.create

the result like this

** (Mix) The database for Sayangku.Repo couldn’t be created: ERROR 42501 (insufficient_privilege) permission
denied to create database

it’s my new User and new Database

AND

You need to add privileges to your account so you will be able to create DBs. For example you can make yourself super admin.