apt install postgresql
Editar o arquivo /etc/postgresql/15/main/postgresql.conf
nano /etc/postgresql/15/main/postgresql.conf
Na linha:
#listen_addresses = 'localhost'
Troque por (acesso somente no Localhost):
listen_addresses = 'localhost'
Troque por (acesso por qualquer máquina):
listen_addresses = '*'
Edite o arquivo nano /etc/postgresql/15/main/pg_hba.conf
nano /etc/postgresql/15/main/pg_hba.conf
Altere o tipo de acesso de:
host all all 127.0.0.1/32 md5host all all ::1/128 md5
Para:
host all all 127.0.0.1/32 trusthost all all ::1/128 trust
Para testar a conectivdade, o sistemas deve retornar uma tabela com o comando:
/usr/bin/psql -h localhost -p 5432 -U postgres -d postgres -c 'SELECT * FROM pg_roles'
rolname | rolsuper | rolinherit | rolcreaterole | rolcreatedb | rolcanlogin | rolreplication | rolconnlimit | rolpassword | rolvaliduntil | rolbypassrls | rolconfig | oid---------------------------+----------+------------+---------------+-------------+-------------+----------------+--------------+-------------+---------------+--------------+-----------+-------pg_signal_backend | f | t | f | f | f | f | -1 | ******** | | f | | 4200pg_read_server_files | f | t | f | f | f | f | -1 | ******** | | f | | 4569 postgres | t | t | t | t | t | t | -1 | ******** | | t | | 10pg_write_server_files | f | t | f | f | f | f | -1 | ******** | | f | | 4570 pg_execute_server_program | f | t | f | f | f | f | -1 | ******** | | f | | 4571pg_read_all_stats | f | t | f | f | f | f | -1 | ******** | | f | | 3375 pg_monitor | f | t | f | f | f | f | -1 | ******** | | f | | 3373dvnapp | f | t | t | t | t | f | -1 | ******** | | f | | 16384 pg_read_all_settings | f | t | f | f | f | f | -1 | ******** | | f | | 3374 pg_stat_scan_tables | f | t | f | f | f | f | -1 | ******** | | f | | 3377 (10 rows)