Site Tools


postgresql
root@db2:/var/log/postgresql# su - postgres
postgres@db2:~$ psql
psql (10.6 (Ubuntu 10.6-0ubuntu0.18.04.1))
Type "help" for help.

postgres=#

pour remote access : https://bosnadev.com/2015/12/15/allow-remote-connections-postgresql-database-server/

edit postgresql.conf et set listen_addresses = '*'

edit pg_hba.conf et set : host all all 0.0.0.0/0 md5 ou alors : ? local all psqldbuser md5

psql boamp
boamp=#create user psqldbuser ;
CREATE ROLE

boamp=# \password psqldbuser
Enter new password:
Enter it again:

boamp=#alter role psqldbuser with Superuser ;
ALTER ROLE
boamp=# \du
                                    List of roles
 Role name  |                         Attributes                         | Member of
------------+------------------------------------------------------------+-----------
 postgres   | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
 psqldbuser | Superuser                                                  | {}

boamp=# \d
                 List of relations
 Schema |         Name          | Type  |  Owner
--------+-----------------------+-------+----------
 public | boamp                 | table | postgres
 public | boamp_source_archives | table | postgres
(2 rows)

boamp=# grant all privileges on boamp to psqldbuser ;
GRANT
boamp=# grant all privileges on boamp_source_archives to psqldbuser ;
GRANT
boamp=# \dp+
                                          Access privileges
 Schema |         Name          | Type  |      Access privileges      | Column privileges | Policies
--------+-----------------------+-------+-----------------------------+-------------------+----------
 public | boamp                 | table | postgres=arwdDxt/postgres  +|                   |
        |                       |       | psqldbuser=arwdDxt/postgres |                   |
 public | boamp_source_archives | table | postgres=arwdDxt/postgres  +|                   |
        |                       |       | psqldbuser=arwdDxt/postgres |                   |
(2 rows)

boamp=#
postgresql.txt · Last modified: 2019/03/20 13:57 (external edit)