Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

Create a PostgreSQL User

This guide shows how to make a new PostgreSQL user and give it a password.

Databases2 min read16 steps

What is a database user?

PostgreSQL, often called Postgres, is a database system. A database stores data in tables. A database user is a name and password that let a person or an app log in to it. It works like a key. Your website uses a user to open its database.

Making a user is not enough. You must also give the user rights to a database. Rights are called privileges. They say what the user may do.

Method 1: cPanel

  1. Log in to cPanel.
  2. In the Databases section, open PostgreSQL Databases.
  3. Scroll to PostgreSQL Users.
  4. Type a user name.
  5. Type a password twice. You can use the Password Generator button.
  6. Click Create User.

Now link the user to a database.

  1. Scroll to Add a User To a Database.
  2. Choose the user and the database from the lists.
  3. Click Submit.
  4. Tick ALL PRIVILEGES if the user should do everything. Click Make Changes.

cPanel adds your account name in front of both names. Write down the full names.

Tip: Make a strong password. Use a mix of letters, numbers and symbols. Keep it in a safe place.

Method 2: Command line (root access)

This is for VPS and dedicated server owners with root access. Root access means full control of the server.

  1. Connect with SSH.
  2. Switch to the postgres user.
su - postgres
  1. Open the Postgres shell.
psql
  1. Create the user. Change the name and password.
CREATE USER myuser WITH PASSWORD 'StrongPassword123';

This makes the user and sets its password.

  1. Give the user rights on a database.
GRANT ALL PRIVILEGES ON DATABASE mydb TO myuser;

This lets myuser use mydb fully.

  1. Leave the shell.
\q

Warning: Do not give rights to more users than needed. Fewer rights means a safer database.

If you do not see PostgreSQL in cPanel, ask Hostvento support whether it is on your plan.

Quick recap

  • A PostgreSQL user is a login for a database.
  • In cPanel, create the user, then add it to a database.
  • With root, use CREATE USER and GRANT.
  • Use strong passwords and give only the rights needed.