Postgres Initial Linux Configuration Guide
Accessing psql sudo -i -u postgres psql Create a new database and user Create a new user: CREATE USER theusername WITH PASSWORD 'thepassword'; Create a new database: CREATE DATABASE thedatabase; Grant privileges: GRANT ALL PRIVILEGES ON DATABASE thedatabase TO theusername; Allow Remote Access Edit postgresql.conf, usually located in /etc/postgresql/<version>/main/, and set listen_addresses = '*'. #------------------------------------------------------------------------------ # CONNECTIONS AND AUTHENTICATION #------------------------------------------------------------------------------ # - Connection Settings - listen_addresses = '*' # what IP address(es) to listen on; # comma-separated list of addresses; # defaults to 'localhost'; use '*' for all # (change requires restart) port = 5432 # (change requires restart) max_connections = 100 # (change requires restart) #reserved_connections = 0 # (change requires restart) #superuser_reserved_connections = 3 # (change requires restart) unix_socket_directories = '/var/run/postgresql' # comma-separated list of directories # (change requires restart) #unix_socket_group = '' # (change requires restart) #unix_socket_permissions = 0777 # begin with 0 to use octal notation # (change requires restart) #bonjour = off # advertise server via Bonjour # (change requires restart) #bonjour_name = '' # defaults to the computer name # (change requires restart) # - TCP settings - # see "man tcp" for details #tcp_keepalives_idle = 0 # TCP_KEEPIDLE, in seconds; # 0 selects the system default #tcp_keepalives_interval = 0 # TCP_KEEPINTVL, in seconds; # 0 selects the system default #tcp_keepalives_count = 0 # TCP_KEEPCNT; # 0 selects the system default #tcp_user_timeout = 0 # TCP_USER_TIMEOUT, in milliseconds; # 0 selects the system default #client_connection_check_interval = 0 # time between checks for client # disconnection while running queries; # 0 for never Edit pg_hba.conf and add a line to allow connections — for example, host all all 0.0.0.0/0 scram-sha-256 — for network access. ...