I was doing some work in Knex today, the fantastic SQL builder for node and needed create a new user. It took some research but here is what I found:
This assumes you’ve already logged into Postgres with another user.
CREATE ROLE myUser WITH LOGIN PASSWORD '';
GRANT ALL PRIVILEGES ON DATABASE "knex_test" TO myUser;
To test it out just log back in.
psql -h localhost -U myUser -d knex_test