Create a new postgres user

To create a new PostgreSQL user, you can use the following command:

CREATE ROLE newuser WITH PASSWORD 'mypassword' CREATEDB;

Here's a breakdown of the options:

You can also add additional options to customize the new user's privileges. For example:

CREATE ROLE newuser WITH PASSWORD 'mypassword' CREATEDB SUPERUSER;

This would create a new user with the ability to create new databases and also grant them superuser privileges.

Alternatively, you can use the CREATE USER command, which is a synonym for CREATE ROLE:

CREATE USER newuser WITH PASSWORD 'mypassword' CREATEDB;

Once you've created the new user, you can grant them specific privileges or roles using the GRANT command. For example:

GRANT USAGE ON SCHEMA public TO newuser;

This would grant the new user the ability to use the public schema.

Note: You can also use the pg_createuser command-line tool to create a new user:

pg_createuser -e newuser -p 'mypassword'

This tool is part of the PostgreSQL distribution and can be used to create new users and roles from the command line.