无法通过Cloud SQL Proxy从Google Compute Engine连接到Google Cloud SQL

时间:2016-07-13 19:42:31

标签: google-compute-engine google-cloud-sql cloud-sql-proxy

我尝试使用Cloud SQL Proxy将GCE实例连接到Cloud SQL实例(第2代)。当我ssh到GCE实例和

<form action="testemail@gmail.com" method="post">
  <fieldset>
    <select name="Colour" id="color" onChange="updatePrice()">
      <option value="Choose a colour">Choose a colour</option>
      <option value="Red" data-price="10">Red</option>
      <option value="Blue" data-price="20">Blue</option>
      <option value="Green" data-price="30">Green</option>
      <option value="Purple" data-price="40">Purple</option>
    </select>
  </fieldset>
  <fieldset>
    <select name="Size" id="size" onChange="updatePrice()">
      <option value="Choose a size">Choose a size</option>
      <option value="Large" data-price="40">Large</option>
      <option value="Medium" data-price="30">Medium</option>
      <option value="Small" data-price="20">Small</option>
      <option value="X Small" data-price="10">X Small</option>
    </select>
  </fieldset>
  <fieldset>
    <select name="Material" id="material" onChange="updatePrice()">
      <option value="Choose a material">Choose a material</option>
      <option value="Cotton" data-price="10">Cotton</option>
      <option value="Polyester" data-price="20">Polyester</option>
      <option value="Wool" data-price="30">Wool</option>
      <option value="Velvet" data-price="40">Velvet</option>
    </select>
  </fieldset>
  <fieldset>
    <div id="price">Total: $0
    </div>
  </fieldset>
  <input type="submit" value="Submit now" />

我得到了

sudo ./cloud_sql_proxy -dir=/cloudsql

我已按照文件说明了 https://cloud.google.com/sql/docs/compute-engine-access#gce-connect-proxy
https://cloud.google.com/sql/docs/sql-proxy

两个实例都在同一个项目中,并且在GCE实例上启用了Cloud SQL API(加上默认实例)。据我了解,默认的GCE服务帐户应该能够对代理进行身份验证。

2016/07/13 18:59:28 Using gcloud's active project: xxxx-0000 2016/07/13 18:59:29 Error listing instances in xxxx-0000: googleapi: Error 403: Access Not Configured. Cloud SQL Administration API has not been used in project 000000000000 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/sqladmin/overview?project=000000000000 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry., accessNotConfigured 2016/07/13 18:59:29 no Cloud SQL Instances found in these projects: [xxxx-0000] cloud_sql_proxy一起使用似乎有效,但尝试连接时-instances也出现错误。

2 个答案:

答案 0 :(得分:1)

根据错误消息,您需要通过访问提供的链接确保启用“Cloud SQL Admin”API。

答案 1 :(得分:0)

如果您使用的是第二代GCloud SQL实例,还有一种GUI方式可以连接您的Compute Engine实例。首先获取计算引擎的外部IP,并将其包含在GCloud SQL仪表板的“授权”选项卡中。这是一个快速video