本文介绍了如何创建GCP Cloud SQL IAM用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里的第一个答案是如何为您的Google Platform Cloud SQL实例创建Cloud SQL IAM用户的指南。

Here is a guide on how to connect after you've created the user.

推荐答案

  1. 在上方工具栏上单击您的实例上的编辑";。转到标志并将cloudsql.iam_authentication";>设置为
  2. (&Q>)

  1. 转到左侧导航窗格上的";用户&q;选项卡&>单击";添加用户帐户

  1. 在主体字段中使用人员的GCP电子邮件地址。任何人都可以创建此帐户,但只有IAM编辑可以更改IAM权限。IAM权限影响GCP对象,而不是数据库对象。无需设置IAM权限即可连接到数据库

  1. 使用实例IP地址和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]";
  1. 通过更改会话测试用户的权限
set session authorization "[email protected]";
  • 重置
reset session authorization;
  1. Now you can connect to the database using the IAM details and Cloud SQL Proxy

这篇关于如何创建GCP Cloud SQL IAM用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 03:42