create user and grant privileges in postgres code example
Example 1: grant all privileges database postgres to user
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA schema_name TO username;
Example 2: create postgres user
CREATE DATABASE yourdbname;
CREATE USER youruser WITH ENCRYPTED PASSWORD 'yourpass';
GRANT ALL PRIVILEGES ON DATABASE yourdbname TO youruser;