Postgres Role Required to Grant CONNECT on Specific Database

database-administrationpostgresqlpsqluser-management

I am trying to GRANT CONNECT on a DATABASE to a user as a schema owner in that database.

The schema owner is not a superuser.

Do I need to be the owner of a database to execute

GRANT CONNECT ON DATABASE DBXXX TO USER_YYY; ??

What role should a user be granted other than superuser to allow it to grant connect?

Best Answer

If you were given CONNECT WITH GRANT OPTION you can then grant connect to others.

If you were not given connect with grant option, you cannot grant it, you will need a superuser to grant you CONNECT GRANT OPTION, or to grant connect to the new user.

A superuser (or database owner) would use this command to grant grant option for connect:

GRANT CONNECT ON DATABASE database_name TO your_username WITH GRANT OPTION;

As a schema owner you can grant usage on your schema to others.