使用服务帐号导入 Google Cloud SQL 的权限 [英] Permissions For Google Cloud SQL Import Using Service Accounts

本文介绍了使用服务帐号导入 Google Cloud SQL 的权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经按照 MySQL 导出指南 成功.

现在,我正在尝试按照 MySQL Import 导入 MySQL 数据库指南.

Now, I'm trying to import MySQL Database following the MySQL Import Guide.

我已检查我正在使用的 service_account_email 的权限,并且我已授予 Admin SQLAdmin Storage 权限.

I've checked the permissions for the service_account_email I'm using, and I have allowed both Admin SQL and Admin Storage permissions.

我能够在本地使用此命令成功激活我的服务帐户:

I was able to successfully activate my service account using this command locally:

gcloud auth activate-service-account <service_account_email> --key-file=<service_account_json_file>  

我运行命令后:

gcloud sql import sql <instance> <gstorage_file> --database=<db_name> --async

我得到了这个信息:

{
  "error": {
    "errors": Array[1][
      {
        "domain": "global",
        "reason": "required",
        "message": "Login Required",
        "locationType": "header",
        "location": "Authorization"
      }
    ],
    "code": 401,
    "message": "Login Required"
  }
}

我尝试过的其他事情

我还尝试使用我的 SQL 实例的 service_account_email,它来自:

I also tried using the service_account_email of my SQL instance, which came from:

gcloud sql instances describe <instance_name>

但是,它似乎有同样的错误.

But, it seems to have the same error.

问题

根据我收到的 REST API JSON 错误,我如何使用 service_account_email 登录",这样我就不会收到 401 错误?p>

Based on the REST API JSON error I'm given, how do I "login" using the service_account_email so I wouldn't get the 401 Error?

推荐答案

问题是关于数据库实例服务帐户对创建的桶的写入权限.解决此问题的步骤

Problem is about the permission of database instance service account to write on created bucket. Steps to solve this issue

1) 转到您的 Cloud SQL 实例并复制实例的服务帐户(Cloud SQL->{实例名称}->OVERVIEW->服务帐户)

1) Go to your Cloud SQL Instance and copy service account of instance (Cloud SQL->{instance name}->OVERVIEW->Service account)

2) 复制服务帐户后,转到要转储的 Cloud Storage Bucket 并为该帐户设置所需的权限(Storage->{bucket name}->permissions->add member).

2) After copy the service account, go the Cloud Storage Bucket where to want to dump and set desired permission to that account (Storage->{bucket name}->permissions->add member).

这篇关于使用服务帐号导入 Google Cloud SQL 的权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆