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
- Log in to cPanel.
- In the Databases section, open PostgreSQL Databases.
- Scroll to PostgreSQL Users.
- Type a user name.
- Type a password twice. You can use the Password Generator button.
- Click Create User.
Now link the user to a database.
- Scroll to Add a User To a Database.
- Choose the user and the database from the lists.
- Click Submit.
- 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.
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.
- Connect with SSH.
- Switch to the postgres user.
su - postgres
- Open the Postgres shell.
psql
- Create the user. Change the name and password.
CREATE USER myuser WITH PASSWORD 'StrongPassword123';
This makes the user and sets its password.
- Give the user rights on a database.
GRANT ALL PRIVILEGES ON DATABASE mydb TO myuser;
This lets myuser use mydb fully.
- 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 USERandGRANT. - Use strong passwords and give only the rights needed.