tags: psql On Ubuntu, to connect: ``` sudo -u postgres psql ``` then ``` create user john createdb; ``` or ``` create user john; alter user john createdb; ``` create with password ``` create user bobbins; alter user bobbins createdb; alter user bobbins password 'snuffle'; ``` # schema privileges ``` CREATE DATABASE EXAMPLE_DB; CREATE USER EXAMPLE_USER WITH ENCRYPTED PASSWORD 'Sup3rS3cret'; GRANT ALL PRIVILEGES ON DATABASE EXAMPLE_DB TO EXAMPLE_USER; \c EXAMPLE_DB postgres # You are now connected to database "EXAMPLE_DB" as user "postgres". GRANT ALL ON SCHEMA public TO EXAMPLE_USER; ``` # Allow Remote Source: [this stackoverflow](https://stackoverflow.com/questions/18580066/how-to-allow-remote-access-to-postgresql-database) In `postgresql.conf` ``` listen_addresses = '*' # allow all ``` and in `pg_hba.conf` ``` host all all 192.168.1.1/24 scram-sha-256 ``` the `systemctl restart` (not just `reload`) the `postgresql` service.