Score:2

How do I give a postgres user all privileges to a specific database?

ng flag

I'm setting up a new database server which I intend to use as a backend for many services. Each of these services generally only care about a single database in the system, so I'd like to isolate the accounts each service connects with to only be able to access that database. The service applications manage their own schema, so I want to give them admin-like privileges to their database, but they should not be able to touch anything else.

Is there a way to set this up in postgres?

This question over on ServerFault suggests a method to grant privileges to a user at a schema-wide level; however, this does not work for databases (Alter Default Privileges In Database xx gives me a syntax error on Database).

Score:0
ng flag

I found the answer almost as soon as I asked. The magic command I was looking for is:

Alter Database xxx Owner To user_xxx;

This is documented in the Alter Database command manual:

https://www.postgresql.org/docs/current/sql-alterdatabase.html

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.