This article is half-done without your Comment! *** Please share your thoughts via Comment ***
The Database security is always one of the major tasks for all the Database Administrators.
I have also prepared one article to create Read only User in PostgreSQL.
In this post, I am sharing small note about REVOKE privileges for newly created Database Users of PostgreSQL.
Before a few days ago, one of the PostgreSQL Junior DBA asked this question on my FB Page. He created one new DB User in PostgreSQL and without giving a any permission that USER can CONNECT to all Databases.
Yes: When you create any new DB User in PostgreSQL, It has a default CONNECT privileges.
But It cannot access any Table or data of Databases, yes It can create new Table in any Database.
To prevent a new User for connecting any existing Database, we should run REVOKE command on particular User or Role.
REVOKE CONNECT privileges from Database:
1 |
REVOKE CONNECT ON DATABASE Database_Name FROM User_Name; |
REVOKE all privileges from Database:
1 |
REVOKE ALL PRIVILEGES ON DATABASE Database_Name FROM User_Name; |
You should GRANT only required Databases:
1 |
GRANT CONNECT ON DATABASE Database_Name TO User_Name; |