PostgreSQL: How to Create User in PostgreSQL

PostgreSQL: How to Create User in PostgreSQL

novicetechie

In PostgreSQL, a user is essentially a role with login privileges. Creating a user allows you to manage access and permissions for your database.

Step-by-Step: Create a PostgreSQL User

Here’s how to create a new user in PostgreSQL:


-- Connect to PostgreSQL CLI (psql)
CREATE USER new_username WITH PASSWORD 'secure_password';

-- To grant login privileges
ALTER USER new_username WITH LOGIN;

You can also grant privileges to the new user as needed:


GRANT ALL PRIVILEGES ON DATABASE your_database TO new_username;

What This Does

  • The CREATE USER statement defines a new login role.
  • ALTER USER … WITH LOGIN ensures the account can connect to databases.
  • GRANT assigns permissions on a specific database.

PostgreSQL considers users and roles as part of its access control system. You can tailor permissions for security and functionality. :contentReference[oaicite:0]{index=0}

Comments

Simple Tech Tips for Everyday Users

Learn easy tech solutions, beginner-friendly tutorials, and simple fixes for your phone, laptop, apps, and internet problems — all in one place.

Explore by Category

About NoviceTechie

NoviceTechie.com is your simple tech helper. We provide beginner-friendly tutorials, how-to guides, and easy troubleshooting tips to make technology easier for everyone — no technical knowledge required.

Latest Posts

Get Simple Tech Tips Weekly

Join our free updates (optional).

Follow Us
NoviceTechie.com — Simple tech tutorials, everyday problem fixes, and easy guides for beginners.