此处的第一个答案是有关如何为 Google Platform Cloud SQL 实例创建 Cloud SQL IAM 用户的指南。
postgres
用户连接到数据库。使用该用户我们可以分配权限。 创建的 IAM 用户对数据库对象具有零权限。grant connect on database database_name to "[email protected]";
-- Grant usage on current objects in a schema
grant all on SCHEMA schema_name to "[email protected]";
grant all on all TABLES in SCHEMA schema_name to "[email protected]";
grant all on all FUNCTIONS IN SCHEMA schema_name to "[email protected]";
grant all on all PROCEDURES IN SCHEMA schema_name to "[email protected]";
grant all on all ROUTINES IN SCHEMA schema_name to "[email protected]";
grant all on all SEQUENCES IN SCHEMA schema_name to "[email protected]";
-- Grant usage of any newly created objects in the future
ALTER DEFAULT PRIVILEGES IN SCHEMA schema_name GRANT all ON FUNCTIONS TO "[email protected]";
ALTER DEFAULT PRIVILEGES IN SCHEMA schema_name GRANT all ON ROUTINES TO "[email protected]";
ALTER DEFAULT PRIVILEGES IN SCHEMA schema_name GRANT all ON SEQUENCES TO "[email protected]";
ALTER DEFAULT PRIVILEGES IN SCHEMA schema_name GRANT all ON TABLES TO "[email protected]";
ALTER DEFAULT PRIVILEGES IN SCHEMA schema_name GRANT all ON types TO "[email protected]";
set session authorization "[email protected]";
reset session authorization;