使用云sql身份验证代理从本地mysql客户端访问Cloud SQL

问题描述 投票:0回答:1

我在从本地/gcloud shell 连接到我的 Cloud SQL - MySQL 实例时遇到问题。根据组织政策,我们不能拥有 mysql 数据库实例的公共 IP。所以我创建了一个 vpc 网络来与此实例一起使用,该实例仅创建了私有 IP 访问。

现在我正在运行 cloud sql auth proxy 并尝试使用本地的 mysql 客户端连接到此实例。但它仍然失败并出现错误 无法连接到实例:配置错误:实例没有“PUBLIC”类型的 IP

这是连接测试输出:

./cloud-sql-proxy --run-connection-test --credentials-file <file> <instance connection name>
2024/01/08 22:13:03 Authorizing with the credentials file at “f”file
2024/01/08 22:13:04 [<instance connection name>] Listening on 127.0.0.1:3306
2024/01/08 22:13:04 The proxy has started successfully and is ready for new connections!
2024/01/08 22:13:04 Connection test started
2024/01/08 22:13:04 Connection test failed
2024/01/08 22:13:04 The proxy has encountered a terminal error: Config error: instance does not have IP of type "PUBLIC" (connection name = "instance connection name")

你能帮忙吗?

google-cloud-platform google-cloud-sql cloud-sql-proxy
1个回答
0
投票

按照文档:https://cloud.google.com/sql/docs/mysql/connect-instance-private-ip 在运行 mySQL 的同一 VPC 网络中创建一个 Compute Engine 虚拟机(源),并且从那里访问 MySQL。

© www.soinside.com 2019 - 2024. All rights reserved.