I am new at Postgresql that’s why I can’t figure out some privileges here.
Database called Denemedb23
is already created. I created the user NoxUser
.
I executed these commands:
REVOKE ALL PRIVILEGES ON DATABASE Denemedb23 FROM public;
GRANT CONNECT ON DATABASE Denemedb23 TO NoxUser;
I want Noxuser
just to be able to login to the database and he should not be able to create table/function etc. But NoxUser
can create a table in the database.
Could you help me to figure out why?
2
Answers
The CONNECT permission in PostgreSQL enables a user to establish a connection to a database, but it does not provide the user the power to create tables or carry out other tasks.
In your instance, you have given NoxUser the CONNECT privilege and removed all database rights from the public role. However, the CREATE privilege on the schema is required in order to create tables.
So, make sure the user does not have the CREATE privilege on the schema in order to accomplish your aim of enabling NoxUser to connect to the database but prevent them from creating tables.
Run these commands, these guarantee that although NoxUser can connect to the Denemedb23 database but cannot create tables in the public schema.
Hope it’s helpful 🙂
Privileges on the database are one thing. Privileges on things in it is another. This:
Effectively means this:
Meanings of these you can see below and in the doc. I’m guessing you could’ve expected
CREATE
to mean something else.You need to revoke their privileges on schema/object level, for example:
On schema level, create means something else, as outlined in the doc linked earlier:
The last command will revoke that on
public
, but you might want to inspect other schemas as well. You can also create a schema namedNoxUser
, and by default their non-schema-qualified commands will target that schema thanks tosearch_path
, before taking a look atpublic
.