How to create user in Azure PostgreSQL

In this article, we will see how to create user in Azure PostgreSQL server.

We are going to create user in Azure MySQL server by using two ways.

1. Using GUI methods.
2. Using Create user statement on psql tool or pgadmin tool.

1. Create User in Azure PostgreSQL Database using Create User command:

Syntax to create PostgreSQL User:

CREATE USER name [ [ WITH ] option [ ... ] ]

Options are:

SUPERUSER | NOSUPERUSER | CREATEDB | NOCREATEDB | CREATEROLE | NOCREATEROLE | INHERIT | NOINHERIT | LOGIN | NOLOGIN | REPLICATION | NOREPLICATION | BYPASSRLS | NOBYPASSRLS | CONNECTION LIMIT connlimit | [ ENCRYPTED ] PASSWORD 'password' | PASSWORD NULL | VALID UNTIL 'timestamp' | IN ROLE role_name [, ...] | IN GROUP role_name [, ...] | ROLE role_name [, ...] | ADMIN role_name [, ...] | USER role_name [, ...] | SYSID uid

Examples:

1. Connect to Azure PostgreSQL from pgadmin.

2. Open query tool by right clicking on any of the available databases as shown below.

How to create user in Azure PostgreSQL

3. Then enter following create user statement and click execute button by selecting entire line.

CREATE USER james password 'James@123';

4. Then, right click on Login/Group Roles and select refresh.

5. After refresh new user will appeared in the logins list.

2. Create User in Azure PostgreSQL Database using GUI method:

1. Right click on Logins/Group Roles and select Create and then select Login/Group-Role.

2. In General tab, provide new username.

3. In Definition tab, provide password, Account expire and Connection limit information.

4. In privileges tab, select the privileges to be granted. Then, click on Save.

5. Once we click on save, new user/role is added to logins/group-roles lists.