In PostgreSQL, a user and a role are actually the same thing —
the difference is only permissions.
CREATE USER xyzis really justCREATE ROLE xyz LOGIN;- That means: the role can log in (has the
LOGINattribute). - If you run
CREATE ROLE xyz;withoutLOGIN, it’s a group role (can’t log in).
So when you ran:
CREATE USER user WITH PASSWORD 'something';
PostgreSQL internally ran:
CREATE ROLE user LOGIN PASSWORD 'something';
✅ That’s correct — your PostgreSQL user (role) was successfully created.
⚙️ Why the output said “CREATE ROLE”
That’s normal and expected in PostgreSQL.
Even when you write CREATE USER, it outputs CREATE ROLE.
So your user is created and working. 🎉
🔍 Let’s Verify
Run these commands to confirm:
sudo -i -u postgres
psql
Then inside psql:
\du
This lists all database roles (users).
You should see something like:
Role name | Attributes | Member of
-----------+--------------------------+-----------
postgres | Superuser, Create role... |
user | Login | {}
(user here is your Ubuntu username, or whatever you used)
Exit:
\q
exit
âś… So, to directly answer your question:
Whether user created or I have to create role for same username as Ubuntu?
Answer:
You already created it. PostgreSQL users are roles with login privileges.
No need to create anything else. âś…
🔒 Optional — make sure your user can connect to iotdb
We can grant privileges again explicitly (safe to repeat):
sudo -i -u postgres
psql
Then inside psql:
GRANT ALL PRIVILEGES ON DATABASE iotdb TO user;
\q
exit