Answer the question
In order to leave comments, you need to log in
Why is the database user not assigned rights?
I'm trying to create a database in postgres11, to which only one user will have all rights. To do this, I create a DB: I create CREATE DATABASE joba_finder;
a user: CREATE USER jf_user WITH PASSWORD 'qwerty';
And I assign him all the privileges over this DB:
GRANT ALL PRIVILEGES ON DATABASE joba_finder to jf_user
joba_finder-# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-------------+----------+----------+-------------+-------------+-----------------------
joba_finder | postgres | UTF8 | ru_RU.UTF-8 | ru_RU.UTF-8 |
postgres | postgres | UTF8 | ru_RU.UTF-8 | ru_RU.UTF-8 |
template0 | postgres | UTF8 | ru_RU.UTF-8 | ru_RU.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | ru_RU.UTF-8 | ru_RU.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
test | postgres | UTF8 | ru_RU.UTF-8 | ru_RU.UTF-8 |
(5 rows)
Answer the question
In order to leave comments, you need to log in
postgres=# CREATE DATABASE joba_finder;
CREATE DATABASE
postgres=# CREATE USER jf_user WITH PASSWORD 'qwerty';
CREATE ROLE
postgres=# \l joba_finder
Список баз данных
Имя | Владелец | Кодировка | LC_COLLATE | LC_CTYPE | Права доступа
-------------+----------+-----------+-------------+-------------+---------------
joba_finder | postgres | UTF8 | ru_RU.UTF-8 | ru_RU.UTF-8 |
(1 строка)
postgres=# GRANT ALL PRIVILEGES ON DATABASE joba_finder to jf_user;
GRANT
postgres=# \l joba_finder
Список баз данных
Имя | Владелец | Кодировка | LC_COLLATE | LC_CTYPE | Права доступа
-------------+----------+-----------+-------------+-------------+-----------------------
joba_finder | postgres | UTF8 | ru_RU.UTF-8 | ru_RU.UTF-8 | =Tc/postgres +
| | | | | postgres=CTc/postgres+
| | | | | jf_user=CTc/postgres
(1 строка)
postgres=# select version();
version
--------------------------------------------------------------------------------------------------------
PostgreSQL 11.2 (Debian 11.2-2) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-2) 8.3.0, 64-bit
(1 строка)
postgres=# select
postgres-# \l joba_finder
Список баз данных
Имя | Владелец | Кодировка | LC_COLLATE | LC_CTYPE | Права доступа
-------------+----------+-----------+-------------+-------------+-----------------------
joba_finder | postgres | UTF8 | ru_RU.UTF-8 | ru_RU.UTF-8 | =Tc/postgres +
| | | | | postgres=CTc/postgres+
| | | | | jf_user=CTc/postgres
(1 строка)
postgres-# 1;
?column?
----------
1
(1 строка)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question