To create user I executed the following queries:
CREATE DATABASE yourdbname;
CREATE USER username WITH ENCRYPTED PASSWORD 'yourpass';
GRANT ALL PRIVILEGES ON DATABASE yourdbname TO username;
I check if user was created this way:
su postgres
bash-4.2$ psql -h localhost -p 5432
psql (12.2)
Type "help" for help.
postgres=# \du
List of roles
Role name | Attributes | Member of
-----------+------------------------------------------------------------+-----------
postgres | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
username | | {}
postgres=#
And now, when I want to connect:
$psql -h localhost -p 5432 -U username
psql: error: could not connect to server: FATAL: database "username" does not exist
Could anyone say how to fix it?