PG Bug reporting form <noreply@postgresql.org> writes:
>> **postgres=> alter database db1 owner to user1;**
>> **2020-04-17 16:37:04.328 CST [4712] ERROR: must be member of role
> "user1"**
> However, "user1" is my created, and "db1" is my created too. Why couldn't I
> chenge owner of "db1" to "user1" directly?
Like it says, you're not a member of role user1. Since you have
createrole privilege, you could make yourself a member:
regression=> grant user1 to root;
GRANT ROLE
and then it'd work. But you didn't. (This is one of the ways that
createrole is less powerful, and less dangerous, than superuser.)
regards, tom lane