gpt4 book ai didi

google-cloud-platform - 无法通过 Cloud Shell By Proxy 通过 Cloud SQL 代理进行连接

转载 作者:行者123 更新时间:2023-12-04 19:33:42 25 4
gpt4 key购买 nike

我正在关注 Django GAE 示例,并且在通过代理从 Google Cloud Shell 连接到 Cloud SQL 实例时遇到问题。可能与权限设置有关,因为我看到请求未授权,

其他语境,

  • “gcloud beta sql connect auth-instance --user=root”连接没有问题。
  • 我有一个 SQL 代理客户端的服务帐户。

  • 我可能会错过一些东西。有人可以解释一下吗?提前致谢。

    提前致谢。

    代理日志:
    ./cloud_sql_proxy -instances=auth-158903:asia-east1:auth-instance=tcp:3306

    2017/02/17 14:00:59 Listening on 127.0.0.1:3306 for auth-158903:asia-east1:auth-instance
    2017/02/17 14:00:59 Ready for new connections
    2017/02/17 14:01:07 New connection for "auth-158903:asia-east1:auth-instance"
    2017/02/17 14:03:16 couldn't connect to "auth-158903:asia-east1:auth-instance": dial tcp 107.167.191.26:3307: getsockopt: connection timed out

    客户端日志:
    mysql -u root -p --host 127.0.0.1
    Enter password:
    ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', system error: 0

    我也尝试使用凭证文件,但仍然没有运气,
    ./cloud_sql_proxy -instances=auth-158903:asia-east1:auth-instance=tcp:3306 -credential_file=Auth-2eede8ae0d0b.jason

    2017/02/17 14:21:36 using credential file for authentication; email=sql-proxy-client@auth-158903.iam.gserviceaccount.com
    2017/02/17 14:21:36 Listening on 127.0.0.1:3306 for auth-158903:asia-east1:auth-instance
    2017/02/17 14:21:36 Ready for new connections
    2017/02/17 14:21:46 New connection for "auth-158903:asia-east1:auth-instance"
    2017/02/17 14:21:48 couldn't connect to "auth-158903:asia-east1:auth-instance": ensure that the account has access to "auth-158903:asia-east1:auth-instance" (and make sure there's no typo in that name). Error during get instance auth-158903:asia-east1:auth-instance: googleapi: **Error 403: The client is not authorized to make this request., notAuthorized**

    最佳答案

    Cloud SQL 代理使用端口 3307,而不是更常见的 MySQL 端口 3306。这是因为它以不同的方式使用 TLS,并且具有不同的 IP ACL。因此,默认情况下,允许 MySQL 流量的防火墙将不允许 Cloud SQL 代理。

    查看您的网络上是否有防火墙阻止了端口 3307。要使用 Cloud SQL 代理,请授权此端口进行出站连接。

    关于google-cloud-platform - 无法通过 Cloud Shell By Proxy 通过 Cloud SQL 代理进行连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42290972/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com