---
description: In this tutorial, you will learn How to Create PostgreSQL User in Pg Admin, Add an existing user to a Database, &amp; PostgreSQL Updating &amp; Deleting USER.
title: How to Create User in PostgreSQL Using PgAdmin
image: https://www.guru99.com/images/create-user-in-postgresql-using-pgadmin.png
---

[Skip to content](#main)

**⚡ Smart Summary**

Creating a user in PostgreSQL can be done visually in pgAdmin or with the CREATE USER command in the SQL Shell. You can then grant privileges with GRANT, modify roles with ALTER USER, and remove accounts with DROP USER.

- 🖱️ **Create in pgAdmin:** Right-click Login/Group Roles, enter a name, set a password and privileges, then save to create the user.
- 💻 **CREATE USER Command:** In the SQL Shell, CREATE USER name WITH options sets login, superuser, and password in one command.
- 🔑 **Grant Access:** GRANT ALL PRIVILEGES ON DATABASE db TO user gives an existing user access to a database.
- 🔧 **ALTER USER:** ALTER USER adjusts a role’s permissions, adding or revoking privileges such as SUPERUSER.
- 🗑️ **DROP USER:** DROP USER removes an account, but only after it no longer owns any database objects.
- 🧾 **Role vs User:** CREATE USER defaults to LOGIN, while CREATE ROLE defaults to NOLOGIN; otherwise they are the same.

Read More

![How to Create User in PostgreSQL Using PgAdmin](https://www.guru99.com/images/create-user-in-postgresql-using-pgadmin.png)

## How to Create PostgreSQL User in PgAdmin

Following is a step by step process on how to create user in PostgreSQL PgAdmin:

**Step 1)** Right click on Login

In the first step, Right click on Login Group Role -> Create -> Click on Login Group Role…

[![Create PostgreSQL User in PgAdmin]()](https://www.guru99.com/images/1/092818_0643_PostgreSQLC1.png)

**Step 2)** Create Login/Group Role

Now, Enter the name for the Login

[![Create PostgreSQL User in PgAdmin]()](https://www.guru99.com/images/1/092818_0643_PostgreSQLC2.png)

**Step 3)** Click on Definition & Enter Details

1. Enter Password
2. An expiry date for the account

[![Create PostgreSQL User in PgAdmin]()](https://www.guru99.com/images/1/092818_0643_PostgreSQLC3.png)

**Step 4)** The Privilege section

1. Toggle Can Login button to YES
2. Toggle Superuser to YES

[![Create PostgreSQL User in PgAdmin]()](https://www.guru99.com/images/1/092818_0643_PostgreSQLC4.png)

**Step 5)** The [SQL](https://www.guru99.com/sql.html) section

1. You will see the SQL query to create a user as per the selections made in previous steps
2. Click Save button

[![Create PostgreSQL User in PgAdmin]()](https://www.guru99.com/images/1/092818_0643_PostgreSQLC5.png)

**Step 6)** Role is created

Now, Role is reflected in the object tree.

[![Create PostgreSQL User in PgAdmin]()](https://www.guru99.com/images/1/092818_0643_PostgreSQLC6.png)

**Step 7)** Create a [Database](https://www.guru99.com/introduction-to-database-sql.html)

Now, assign owner myguru to it as shown in below create user Postgres example.

[![Create PostgreSQL User in PgAdmin]()](https://www.guru99.com/images/1/092818_0643_PostgreSQLC7.png)

**Step 8)** The command line

Now, you can see the owner is myguru.

[![Create PostgreSQL User in PgAdmin]()](https://www.guru99.com/images/1/092818_0643_PostgreSQLC8.png)

## PostgreSQL Create a User SQLShell (Command Line)

You can create a user by using the command-line command

**CREATE USER**

This Postgres create user with password method is more convenient for programmers and administrators as they have access to the console of PostgreSQL server. Moreover, they need for Postgres user creation and execute with a single command in place of logging in and using the interface of the PostgreSQL client.

**Syntax:**

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

where option can be:

      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
```

**Example:**

```
CREATE USER tom;
```

will create a user tom

```
CREATE USER tom WITH SUPERUSER;
```

Will create a user tom with superuser privileges. Let’s see the following example.

**Step 1)** We are creating a superuser valid till 3<sup>rd</sup> April 2025 11:50:38 IST. Enter the following command

```
CREATE USER mytest WITH
	LOGIN
	SUPERUSER
	CREATEDB
	CREATEROLE
	INHERIT
	NOREPLICATION
	CONNECTION LIMIT -1
	VALID UNTIL '2025-04-03T11:50:38+05:30'
	PASSWORD '123456';
```

[![Create a User SQLShell]()](https://www.guru99.com/images/1/092818_0643_PostgreSQLC9.png)

**Step 2)** Enter command \\du into the checklist of users

[![Create a User SQLShell]()](https://www.guru99.com/images/1/092818_0643_PostgreSQLC10.png)

**NOTE:** CREATE USER is same as CREATE ROLE command. The difference between the two commands is when the Postgres CREATE user command is written it is by default in the LOGIN state whereas NOLOGIN is assumed when the CREATE ROLE option is used.

## Add an existing user to a Database

You can grant a user privileges to access a database.

Example, we grant user “mytest” all privileges on user guru99

```
GRANT ALL PRIVILEGES ON DATABASE guru99 TO mytest;
```

[![Add an existing user to a Database]()](https://www.guru99.com/images/1/092818_0643_PostgreSQLC11.png)

After execution of the [PostgreSQL](https://www.guru99.com/postgresql-tutorial.html) add user command, user will able to access the database with the given permissions.

The command GRANT is very powerful. You can give granular privileges like Select, Insert, Update to a user.

**Don't Miss:**

- [PostgreSQL Tutorial for Beginners](https://www.guru99.com/postgresql-tutorial.html)
- [PostgreSQL Array: Functions, Type, Example](https://www.guru99.com/postgresql-array-functions.html)
- [PostgreSQL SUBSTRING() Function with Regex Example](https://www.guru99.com/postgresql-substring.html)
- [PostgreSQL INSERT: Inserting Data into a Table](https://www.guru99.com/postgresql-insert.html)

## PostgreSQL Updating USER

### Altering Existing User Permissions

Now that our new user “mytest” exists you can use ALTER USER to change the permissions granted to the librarian.

The format of ALTER USER Postgres includes the name of the user followed by some options to tell PostgreSQL which permissive alterations to make:

```
ALTER USER role_specification WITH OPTION1 OPTION2 OPTION3;
```

### Revoking Permissions

You need to use this command when you make a mistake and wrongly assign permission which you may want to revoke. You can use ALTER USER command with no prefix before the permissive options.

For example, we can remove the SUPERUSER status from mytest like:

```
ALTER USER mytest WITH NOSUPERUSER;
```

Using \\du, you will observe that the Superuser privilege is removed.

[![Revoking Permissions]()](https://www.guru99.com/images/1/092818_0643_PostgreSQLC12.png)

### Assigning Permission

You can use user SUPERUSER permission back “mytest” using the following command

```
ALTER USER mytest WITH SUPERUSER;
```

Using \\du, you will observe that the Superuser privilege is added.

[![Assigning Permission]()](https://www.guru99.com/images/1/092818_0643_PostgreSQLC13.png)

## PostgreSQL Deleting User

You can use delete any user if you are sure that the specific user is no longer for your database. Note that deleting the users will never affect the actual database.

```
Syntax: DROP USER [user]
```

To delete any user, you have to make certain that the user is an owner of the database. Otherwise, you may receive an error message.

```
ERROR:  role "username" cannot be dropped because some objects depend on it
```

**Example:**

1. Account “myguru” is an owner of database “demoDB.”
2. Enter command DROP USER myguru
3. Error is shown

[![PostgreSQL Deleting User]()](https://www.guru99.com/images/1/092818_0643_PostgreSQLC14.png)

Once we change the database owner, the user can be deleted

[![PostgreSQL Deleting User]()](https://www.guru99.com/images/1/092818_0643_PostgreSQLC15.png)

## Cheat Sheet

Here are important commands

| Commands | Description |
| --- | --- |
| <pre>CREATE USER [user]</pre> | Command to Create a User |
| <pre>ALTER USER role_specification</pre> | Altering Existing User Permissions |
| <pre>ALTER USER [user]</pre> | Revoking Permissions |
| <pre>ALTER USER [user name] WITH SUPERUSER</pre> | Assigning Permission |
| <pre>DROP USER [user]</pre> | Command to Delete a User |

## FAQs

📋 How do you list all users in PostgreSQL?

In the psql shell, run the \\du command to list all roles and their attributes. You can also query the system catalog with SELECT rolname FROM pg\_roles to get the same information programmatically.

🔑 How do you change a PostgreSQL user’s password?

Use ALTER USER, for example ALTER USER mytest WITH PASSWORD ‘newpassword’. The change takes effect immediately. Passwords are stored encrypted, and only superusers or the user themselves can change them.

🧾 What is the difference between a role and a user in PostgreSQL?

In PostgreSQL, users and roles are the same object. CREATE USER creates a role that can log in by default, while CREATE ROLE creates one that cannot log in unless you add the LOGIN attribute.

🤖 How can AI help manage PostgreSQL users and permissions?

AI can generate CREATE USER, GRANT, and ALTER USER statements from a plain description of the access you need, and explain each privilege. This helps you apply least-privilege security without memorizing syntax.

🤖 Can AI help write secure GRANT statements in PostgreSQL?

Yes. AI can suggest granular GRANT commands that give only the required privileges, warn against granting broad superuser access, and recommend using roles to group permissions for easier, safer management.

#### Summarize this post with:

ChatGPTPerplexityGrokGoogle AI

**Stay Updated on AI** **Get Weekly AI Skills, Trends, Actionable Advice.**

##### Sign up for the newsletter

Subscribe for Free

You have successfully subscribed.  
Please check your inbox.

![AI-Newsletter]() Chosen by over **350,000+** professionals

[Scroll to top](#wrapper)

×

Search for:

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://www.guru99.com/#organization","name":"Guru99","sameAs":["https://www.facebook.com/Guru99Official","https://twitter.com/guru99com"],"logo":{"@type":"ImageObject","@id":"https://www.guru99.com/#logo","url":"https://www.guru99.com/images/guru99-logo-v1-150x59.png","contentUrl":"https://www.guru99.com/images/guru99-logo-v1-150x59.png","caption":"Guru99","inLanguage":"en-US"}},{"@type":"WebSite","@id":"https://www.guru99.com/#website","url":"https://www.guru99.com","name":"Guru99","publisher":{"@id":"https://www.guru99.com/#organization"},"inLanguage":"en-US"},{"@type":"ImageObject","@id":"https://www.guru99.com/images/create-user-in-postgresql-using-pgadmin.png","url":"https://www.guru99.com/images/create-user-in-postgresql-using-pgadmin.png","width":"700","height":"250","caption":"Create User in PostgreSQL Using pgAdmin","inLanguage":"en-US"},{"@type":"BreadcrumbList","@id":"https://www.guru99.com/postgresql-create-alter-add-user.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":"1","item":{"@id":"https://www.guru99.com","name":"Home"}},{"@type":"ListItem","position":"2","item":{"@id":"https://www.guru99.com/postgresql","name":"PostgreSQL"}},{"@type":"ListItem","position":"3","item":{"@id":"https://www.guru99.com/postgresql-create-alter-add-user.html","name":"How to Create User in PostgreSQL Using PgAdmin"}}]},{"@type":"WebPage","@id":"https://www.guru99.com/postgresql-create-alter-add-user.html#webpage","url":"https://www.guru99.com/postgresql-create-alter-add-user.html","name":"How to Create User in PostgreSQL Using PgAdmin","dateModified":"2026-10-08T16:58:41+05:30","isPartOf":{"@id":"https://www.guru99.com/#website"},"primaryImageOfPage":{"@id":"https://www.guru99.com/images/create-user-in-postgresql-using-pgadmin.png"},"inLanguage":"en-US","breadcrumb":{"@id":"https://www.guru99.com/postgresql-create-alter-add-user.html#breadcrumb"}},{"@type":"Person","@id":"https://www.guru99.com/author/editorial","name":"Editorial Team","url":"https://www.guru99.com/author/editorial","image":{"@type":"ImageObject","@id":"https://www.guru99.com/images/favicon-new-logo.png","url":"https://www.guru99.com/images/favicon-new-logo.png","caption":"Editorial Team","inLanguage":"en-US"},"sameAs":["https://www.guru99.com/editorial-team"],"worksFor":{"@id":"https://www.guru99.com/#organization"}},{"articleSection":"PostgreSQL","headline":"How to Create User in PostgreSQL Using PgAdmin","description":"In this tutorial, you will learn How to Create PostgreSQL User in Pg Admin, Add an existing user to a Database, &amp; PostgreSQL Updating &amp; Deleting USER.","keywords":"postgresql, sql","speakable":{"@type":"SpeakableSpecification","cssSelector":[".entry-title",".summary"]},"@type":"Article","author":{"@id":"https://www.guru99.com/author/editorial","name":"Editorial Team"},"dateModified":"2026-10-08T16:58:41+05:30","image":{"@id":"https://www.guru99.com/images/create-user-in-postgresql-using-pgadmin.png"},"copyrightYear":"2026","name":"How to Create User in PostgreSQL Using PgAdmin","subjectOf":[{"@type":"HowTo","name":"How to Create PostgreSQL User in PgAdmin","description":"Following is a step by step process on how to create user in PostgreSQL PgAdmin:","step":[{"@type":"HowToStep","name":"Step 1) Right click on Login","text":"In the first step, Right click on Login Group Role -&gt; Create -&gt; Click on Login Group Role\u2026","image":{"@type":"ImageObject","url":"https://cdn.guru99.com/images/1/092818_0643_PostgreSQLC1.png"},"url":"https://www.guru99.com/postgresql-create-alter-add-user.html#step1"},{"@type":"HowToStep","name":"Step 2) Create Login/Group Role","text":"Now Enter the name for the Login","image":{"@type":"ImageObject","url":"https://cdn.guru99.com/images/1/092818_0643_PostgreSQLC2.png"},"url":"https://www.guru99.com/postgresql-create-alter-add-user.html#step2"},{"@type":"HowToStep","name":"Step 3) Click on Definition &amp; Enter Details","text":"Click on Definition and Enter Password, An expiry date for the account.","image":{"@type":"ImageObject","url":"https://cdn.guru99.com/images/1/092818_0643_PostgreSQLC3.png"},"url":"https://www.guru99.com/postgresql-create-alter-add-user.html#step3"},{"@type":"HowToStep","name":"Step 4) The Privilege section","text":"In the privilege section, Toggle Can Login button to YES, and Toggle Superuser to YES.","image":{"@type":"ImageObject","url":"https://cdn.guru99.com/images/1/092818_0643_PostgreSQLC4.png"},"url":"https://www.guru99.com/postgresql-create-alter-add-user.html#step4"},{"@type":"HowToStep","name":"Step 5) SQL section","text":"Now You will see the SQL query to create a user as per the selections made in previous steps.","image":{"@type":"ImageObject","url":"https://cdn.guru99.com/images/1/092818_0643_PostgreSQLC5.png"},"url":"https://www.guru99.com/postgresql-create-alter-add-user.html#step5"},{"@type":"HowToStep","name":"Step 6) Role is created","text":"Now Role is created and reflected in the object tree.","image":{"@type":"ImageObject","url":"https://cdn.guru99.com/images/1/092818_0643_PostgreSQLC6.png"},"url":"https://www.guru99.com/postgresql-create-alter-add-user.html#step6"},{"@type":"HowToStep","name":"Step 7) Create a Database","text":"Now Create a Database and assign owner myguru to it as shown in below create user Postgres example.","image":{"@type":"ImageObject","url":"https://cdn.guru99.com/images/1/092818_0643_PostgreSQLC7.png"},"url":"https://www.guru99.com/postgresql-create-alter-add-user.html#step7"},{"@type":"HowToStep","name":"Step 8) The Command line","text":"Now, you can see the owner is myguru.","image":{"@type":"ImageObject","url":"https://cdn.guru99.com/images/1/092818_0643_PostgreSQLC8.png"},"url":"https://www.guru99.com/postgresql-create-alter-add-user.html#step8"}]},{"@type":"FAQPage","mainEntity":[{"@type":"Question","name":"How do you list all users in PostgreSQL?","acceptedAnswer":{"@type":"Answer","text":"In the psql shell, run the du command to list all roles and their attributes. You can also query the system catalog with SELECT rolname FROM pg_roles to get the same information programmatically."}},{"@type":"Question","name":"How do you change a PostgreSQL user's password?","acceptedAnswer":{"@type":"Answer","text":"Use ALTER USER, for example ALTER USER mytest WITH PASSWORD 'newpassword'. The change takes effect immediately. Passwords are stored encrypted, and only superusers or the user themselves can change them."}},{"@type":"Question","name":"What is the difference between a role and a user in PostgreSQL?","acceptedAnswer":{"@type":"Answer","text":"In PostgreSQL, users and roles are the same object. CREATE USER creates a role that can log in by default, while CREATE ROLE creates one that cannot log in unless you add the LOGIN attribute."}},{"@type":"Question","name":"How can AI help manage PostgreSQL users and permissions?","acceptedAnswer":{"@type":"Answer","text":"AI can generate CREATE USER, GRANT, and ALTER USER statements from a plain description of the access you need, and explain each privilege. This helps you apply least-privilege security without memorizing syntax."}},{"@type":"Question","name":"Can AI help write secure GRANT statements in PostgreSQL?","acceptedAnswer":{"@type":"Answer","text":"Yes. AI can suggest granular GRANT commands that give only the required privileges, warn against granting broad superuser access, and recommend using roles to group permissions for easier, safer management."}}]}],"@id":"https://www.guru99.com/postgresql-create-alter-add-user.html#schema-29331","isPartOf":{"@id":"https://www.guru99.com/postgresql-create-alter-add-user.html#webpage"},"publisher":{"@id":"https://www.guru99.com/#organization"},"inLanguage":"en-US","mainEntityOfPage":{"@id":"https://www.guru99.com/postgresql-create-alter-add-user.html#webpage"}}]}
```
