PostgreSQL: Prevent New User to access Newly Created Database

This is also one of the important discussion for PostgreSQL Professional.
In PostgreSQL, when you create a new user without specifying any grant or rule, by default it user has access to all databases.

Postgres internally provides PUBLIC grant to newly created user.

As we are Database Proffesional and database security is one of major concern for us.

You can refer this article to create, read only user in PostgreSQL.

If you want to prevent user to access all databases, use below REVOKE script.

My advice is to always create your customize database role for application and read only user.

After executing this revoke command, you can grant this CONNECT to your Database Role.

Anvesh Patel

Leave a Reply

Be the First to Comment!

Notify of