Z
Z
zlodiak2019-04-05 16:10:28
PostgreSQL
zlodiak, 2019-04-05 16:10:28

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

But as a result, there is no information in the access column in the database list that the user jf_user has all the privileges to work in this database:
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)

Please help fix this.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Melkij, 2019-04-05
@zlodiak

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 строка)

just works. This is not regulated by the settings, so check what you are doing wrong. Maybe don't commit the transaction with grant? Don't know.
joba_finder-# \l
Attention to -# so where =# should be - the label indicates that you started writing the query but didn't complete it. psql commands like \l are still processed.
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 строка)

As an example psql command in the middle of writing select 1;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question