By default, Plesk creates a database user with full privileges on its database.
So after database user creation, you can provide it with a read-only permission directly from PostgreSQL side using the following commands:
1. Login as postgres admin:

sudo -i -u postgres

2. Login to your database (replace database_name with your actual database):

psql database_name

3. Grant CONNECT and SELECT permissions on the database:

GRANT CONNECT ON DATABASE database_name TO readonly_user;

4. Grant usage on schema:

GRANT USAGE ON SCHEMA public TO readonly_user;

5. Grant SELECT on all existing tables:

GRANT SELECT ON ALL TABLES IN SCHEMA public TO readonly_user;

6. Make future tables also readable automatically:

ALTER DEFAULT PRIVILEGES IN SCHEMA public
GRANT SELECT ON TABLES TO readonly_user;


For more information about granting permissions, please refer to the official PostgreSQL documentation:
https://www.postgresql.org/docs/current/sql-grant.html?

Was this answer helpful? 0 Users Found This Useful (0 Votes)